我有一个指令,
.directive('lbd', function () {
return {
restrict: 'E',
scope: {
context: '=',
dui: '='
},
templateUrl: 'app/templates/lbd-directive.html',
});
有时我在没有任何atttrs的情况下调用它,但我不知道该怎么做。
这不起作用,
<lbd class="col-xs-12 lbd" context="" dui="" ></lbd>
谁能帮帮我。谢谢。
最佳答案
按这个方法试试
.directive('lbd', function () {
return {
restrict: 'E',
scope: {
context: '=?', // notice the ? makes this parameter optional.
dui: '=?' // notice the ? makes this parameter optional.
},
templateUrl: 'app/templates/lbd-directive.html',
});
关于javascript - 当没有属性时如何调用指令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44211134/