如何设置类似于:
的元素/属性指令<div directive="string"></div>
和
restrict: 'EA',
scope: {
value: '=' || '=directive' // ???
}
其中字符串值在范围内是否相同?
ngInclude
我知道src=""
使用text-fill-color
答案 0 :(得分:1)
您可以使用ngInclude
工具代码,因为attrs['blob']
为您提供String
,而您的价值typeof
为String
,因此它适用于您的情况。<登记/>
但如果您的值为Object
或Number
,则应使用$eval
或$parse
将其值从String
转换为scope.value = scope.$eval(attrs.value || attrs.directive);
。
scope: {
directive: '=?',
value: '=?'
},
link: function(scope) {
scope.value = scope.value || scope.directive;
}
或者只是你可以这样做:
insert 1 10