这是我的代码。
<i class="errorfield" ng-if="rigst.secretans === rigst.password" ng-show="(registration.secretanswer.$dirty || submitted) && registration.secretanswer.$invalid">
<span>
<img class="error" src="./img/errorimage.png" />
</span>
</i>
我想将angularjs ng-show和ng-if组合在一行中以在输入元素上产生错误。
答案 0 :(得分:0)
我想以下任何一种都适合你。 ng-if修改dom而ng-show没有。选择相应的。
<i class="errorfield"
ng-if="(rigst.secretans === rigst.password)&&((registration.secretanswer.$dirty || submitted) && registration.secretanswer.$invalid)">
<span> <img class="error" src="./img/errorimage.png" />
</span>
</i>
<i class="errorfield"
ng-show="(rigst.secretans === rigst.password)&&((registration.secretanswer.$dirty || submitted) && registration.secretanswer.$invalid)">
<span> <img class="error" src="./img/errorimage.png" />
</span>
</i>
<i class="errorfield" ng-if="rigst.secretans === rigst.password">
<div
ng-show="(registration.secretanswer.$dirty || submitted) && registration.secretanswer.$invalid">
<span> <img class="error" src="./img/errorimage.png" />
</span>
</div>
</i>