我有一个指令,其中包含一个用于模板的函数。
因为我希望基于其他值来呈现不同的模板。
restrict: 'E', // 'A' is the default, so you could remove this line
scope: {
field : '@field',
},
template: function( element, attrs) {
//some code here
},
link: function (scope, element, attrs) {
从模板函数中访问指令作用域是否可能?我想做类似于:
if (scope.columnType == 'test'){ .. }
因为我希望基于其他值来呈现不同的模板。