How to set a native attribute from AngularJS directive?

前端 未结 3 1331
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-30 03:39

I\'d like to write HTML similar to:

test

And ha

3条回答
  •  被撕碎了的回忆
    2020-12-30 04:24

    A custom filter is much more suited for this case than a directive:

    test
    
    

    The filter: (Assuming you have a global filters module)

    angular.module('filters').filter('fullPath', function(globalVars) {
      return function(url) {
        return globalVars.staticWebsite + "/app/styles/main/" + url + "?build=" + globalVars.buildNumber;
      };
    });
    

提交回复
热议问题