ng-click 不适用于 ng-if [英] ng-click not working with ng-if
本文介绍了ng-click 不适用于 ng-if的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么使用 ng-if 时第二个按钮不起作用?
我想实现一个按钮,它只在模型值被设置/不"/不为空时才出现.
I want to realize a button that is present only when the model value is set / not ""/ not null.
模板:
<input type="text" ng-model="blub"/>
<br/>
<button ng-click="blub = 'xxxx'">X</button>
<br/>
<button ng-click="blub = 'yyyy'" ng-if="blub.length">Y</button>
控制器:
angular.module('test', [])
.controller('Main', function ($scope) {
// nothing to do here
});
玩转:JSFiddle
推荐答案
使用 ng-show
而不是 ng-if
.那应该可行.
这篇关于ng-click 不适用于 ng-if的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文