如果条件为{{variable.value}}
我不知道怎么做,我正在使用div:
<div ng-if="true">{{variable.value}}</div>
但我想仅使用值而非HTML来设置条件,这是可能的吗?
感谢。
答案 0 :(得分:0)
如果我理解,您可以使用ng-show:https://docs.angularjs.org/api/ng/directive/ngShow
<div ng-show="variable.value">{{variable.value}}</div>
答案 1 :(得分:0)
您可以执行以下操作。
"use babel"
angular.module('app', []).component('home', {
controller: function() {
this.$onInit = () => {
this.name = 'David'
}
},
template: `<form name="myForm">
<label>I agree to terms
<input type="checkbox" ng-model="$ctrl.terms">
</label><br/>
<p ng-if="$ctrl.terms">You have agreed to terms, {{$ctrl.name}}</p>
</form>`
})
答案 2 :(得分:0)
你最初初始化你的ng-if测试
NG-模型=&#34; myStaff&#34; ng-init =&#34; myStaff = true&#34;
之后
{{variable.value}}答案 3 :(得分:0)
<div ng-if="option.isVisible">{{variable.value}}</div>
和
<div ng-show="option.isVisible">{{variable.value}}</div>