首页 > 如何动态修改directive templateUrl的值

如何动态修改directive templateUrl的值

home.directive("content",function(){

        return {
            restrict:"E",
            templateUrl:""
        }
    });

templateUrl可以返回一个函数:

home.directive('componentA', function() {
   return {
       restrict: 'E',
       link: function(scope, element, attrs) {
           //
       },
       templateUrl: function(elem,attrs) {
           return attrs.templateUrl || './default.html'
       }
   }
});
【热门文章】
【热门文章】