Issue
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">
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.
Solution
Don't put any Condition Expression in Template.
Do it at the Controller.
Template:
<input ng-click="check(profileForm.$valid)" name="submit"
id="submit" value="Save" class="submit" type="submit">
Controller:
$scope.check = function(value) {
if (value) {
updateMyProfile();
}
}
Answered By - Chen-Tsu Lin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.