我正在尝试在指令中使用多个 ng-bind 而不是 {{}} ,但没有运气。
<my-directive att1="age" att2="22"></my-directive>
angular
.module("app",[])
.directive('myDirective', myDirective);
function myDirective() {
return {
restrict: 'E',
scope: {
att1: '@',
att2: '@'
},
template: '<div class="ng-bind: att1;" ng-bind="att2"></div>'
}
}
万一只有一个 ng-bind 也没问题。如果我有不止一个,就像在这种情况下,我在某处读到了我正在使用的符号,"ng-bind: att;"
但它不起作用。
另外,我想知道我是否真的需要它。显然使用 ng-bind 避免了双括号在加载数据之前在屏幕中闪烁的问题,在这种情况下,这并不重要,因为我将值用作类属性,因此不会显示在屏幕中. 另一方面,使用 ng-bind 应该更有效。
有任何想法吗?我在stackoverflow中看到了一些关于此的问题,但似乎都没有解决这个问题。