Created
September 18, 2014 15:52
-
-
Save Nate-Wilkins/58f1999d6354ad452d97 to your computer and use it in GitHub Desktop.
templateUrl custom directive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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