If you need to do it this way, here are a few ways to do it:
Disabling a button with ng-disabled
Today it is the easiest solution.
<input ng-disabled="!profileForm.$valid" ng-click="updateMyProfile()" ... >
Hiding a button (and showing something else) with ng-if
It might be nice if you show / hide some complex markup.
<div ng-if="profileForm.$valid"> <input ng-click="updateMyProfile()" ... > </div> <div ng-if="!profileForm.$valid"> Sorry! We need all form fields properly filled out to continue. </div>
(remember that there is no ng-else ...)
Connection of both
Communicating with the user where the button is located (he will no longer search for it), but explain why you can’t click it.
<input ng-disabled="!profileForm.$valid" ng-click="updateMyProfile()" ... > <div ng-if="!profileForm.$valid"> Sorry! We need all form fields properly filled out to continue. </div>
Björn Ali Göransson Nov 08 '15 at 21:29 2015-11-08 21:29
source share