NG-点击不工作的NG-如果 [英] ng-click not working with ng-if

查看:182
本文介绍了NG-点击不工作的NG-如果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么第二个按钮不起作用,NG-如果在使用?

我想实现一个按钮,为present仅当模型值设置/不是/ NOT NULL。

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

To play around: JSFiddle

推荐答案

使用 NG-节目 相反的NG-如果。这应该工作。

<大骨节病> 小提琴

这篇关于NG-点击不工作的NG-如果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆