在项目中,由于要兼容到IE8,我使用1.2.8版本的angularJS。这个版本是支持自定义指令的。
原本的代码写法:
HTML:
<pagination></pagination>
JS:
.directive('pagination', ["$rootScope", function ($rootScope) { return { restrict: 'E', templateUrl: "./html/maintain/pagination.html", link: function ($scope, elem, attr) { ... ... }; } }; }]);
能够兼容IE8的写法:
HTML:
<div pagination></div>
JS:
.directive('pagination', [ "$rootScope", function ($rootScope) { return { templateUrl: "./html/maintain/pagination.html", link: function ($scope, elem, attr) { ... ... } }; }]);