在下面的代码中,{{ }}
中的所有内容都会更新,但ng-show
和ng-class
等指令不会重新运行?... objects
时已更新。编译模板时,它们会运行一次,我假设。
<div>
<div
ng-repeat="object in $ctrl.objects"
>
<div>
{{ $ctrl.showStatus(object.property) }}
</div>
<div>
{{ $ctrl.getClassName(object.property) }}
</div>
<div
ng-show="$ctrl.showStatus(object.property)"
ng-class="$ctrl.getClassName(object.property)">
{{ object.name }} - {{ object.property }}
</div>
</div>
</div>
mod.component('pane', {
bindings: {
objects: '='
},
controller: function ($scope, $element, $attrs, service) {
this.getClassName = function (property) {
return 'status-'+property.state.name()+'-state';
};
this.showStatus = function (property) {
return property.state !== service.AlarmStates.OK;
};
},
templateUrl: "/templates/panes/alert.html"
});