Skip to content

Instantly share code, notes, and snippets.

@Nate-Wilkins
Created September 18, 2014 15:52
Show Gist options
  • Save Nate-Wilkins/58f1999d6354ad452d97 to your computer and use it in GitHub Desktop.
Save Nate-Wilkins/58f1999d6354ad452d97 to your computer and use it in GitHub Desktop.
templateUrl custom directive
// taken from: https://github.com/esvit/ng-table/blob/master/ng-table.js
scope: {
'params': '=ngTablePagination',
'templateUrl': '='
},
replace: false,
link: function (scope, element, attrs) {
scope.params.settings().$scope.$on('ngTableAfterReloadData', function () {
scope.pages = scope.params.generatePagesArray(scope.params.page(), scope.params.total(), scope.params.count());
}, true);
scope.$watch('templateUrl', function(templateUrl) {
if (angular.isUndefined(templateUrl)) {
return;
}
var template = angular.element(document.createElement('div'))
template.attr({
'ng-include': 'templateUrl'
});
element.append(template);
$compile(template)(scope);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment