Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set button value in angularjs

Tags:

angularjs

Button:

<input type="submit" value="{loading : 'please wait...', !loading : 'start'}" />

However this does not work. I get the expression as value instead of please wait/start. Is there a built in angular directive to do this?

like image 344
UpCat Avatar asked Mar 27 '26 21:03

UpCat


2 Answers

Maybe you are looking something like

<input type="submit" value="{{loading && 'please wait...' || 'start'}}" />

It works like ternary operator.

And if you are using Angular 1.1.5 or above this would work

<input type="submit" value="{{loading ? 'please wait...' : 'start'}}" />
like image 111
Chandermani Avatar answered Mar 29 '26 12:03

Chandermani


This may be old, but I thought I'd add this answer for button specific tag, since setting the value of button wasn't working for me. I needed to add this as follows.

<button type="button" ng-click="actionAll();" 
             class="btn btn-default">{{loading ? 'please wait...' : 'start'}}</button>
like image 30
Christian Phillips Avatar answered Mar 29 '26 11:03

Christian Phillips



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!