如果NG-点击声明 [英] if statement in ng-click

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

问题描述

有没有办法把一个条件内的NG-点击的方法吗?在这里,我想,如果有任何形式的错误的形式没有提交,但后来我得到了一个分析异常。

Is there a way to put a condition inside an ng-click? Here, I want that the form is not submitted if there are any form errors, but then I got a parse exception.

 <input  ng-click="{{if(profileForm.$valid) updateMyProfile()}}" name="submit" id="submit" value="Save" class="submit" type="submit">

我试图用NG-禁止,但随后我的验证插件不工作的原因形式从来没有在所有提交的,所以它不会被触发。

I tried to use ng-disabled but then my validation plugin does not work cause form is never submitted at all, so it is not triggered.

推荐答案

模板:

<input ng-click="check(profileForm.$valid)" name="submit" 
       id="submit" value="Save" class="submit" type="submit">

控制器:

$scope.check = function(value) {
    if (value) {
       updateMyProfile();
    }
}

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

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