javascript - How can I change the text of a button when it is disabled using AngularJS? -
i have save button disabled when form pristine. want saved when pristine , change save when form dirty. working fine except text change button. here code:
<input type="button" value="saved" class="button success radius expand" ng-click="save(form)" ng-disabled="!signupform.$dirty" ng-class="{disabled:!signupform.$dirty}">
if want make inline do:
<input type="button" value="{{(signupform.$dirty)? 'save' : 'saved'}}" class="button success radius expand" ng-click="save(form)" ng-disabled="!signupform.$dirty" ng-class="{disabled:!signupform.$dirty}">
you can create function in controller return text. can useful if logic larger (different texts various specific cases).
html
<input type="button" value="{{getinputtext()}}" class="button success radius expand" ng-click="save(form)" ng-disabled="!signupform.$dirty" ng-class="{disabled:!signupform.$dirty}">
controller:
function getinputtext(form) { return (form.$dirty)? 'save' : 'saved'; }