有没有办法将自定义筛选器作为属性传递到自定义指令中?所以如果我有指令
<my-element value="1234" filter="my-filter:attr1:attr2"><my-element>
作为
angular.module("directives", ["filter"]).directive("myElement", function() {
return {
restrict: "E",
replace : true,
scope : {
value : "@",
filter : "@"
},
template: function (el, attr) {
return "<p>{{value | filter}}</p>";
},
link: function($scope){ /* linking stuff */ }
};
});
带过滤器:
angular.module("filter", []).filter("myFilter", function() {
return function(value, attr1, attr2) {
return "filtered value";
};
};
});
只是什么都没发生,我不知道这里出了什么问题。。。
您是否将这两个模块注入到应用程序模块中?像这样:
angular.module("app", ["filter","directives"])