AngularJS自定义指令(Directives)兼容IE8的方法

在项目中,由于要兼容到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) {
                ... ...
            }
        };
    }]);

 

posted @ 2017-12-21 11:25  miny_simp  阅读(261)  评论(0编辑  收藏  举报