Samantha J T Star
Samantha J T Star

Reputation: 32838

How can I make the text of a button change in AngularJS?

I have a button in HTML:

<button>     </button>

How can I make the change inside change depending on the value of a $scope variable?

$scope.action == Action.Authenticating

I would like it to say "Sign in" when this is false and "Signing in..." when it is true.

Upvotes: 1

Views: 49

Answers (2)

Josh
Josh

Reputation: 44916

You can use the ternary operator inside a binding:

<button>{{action === "someValue" ? "Primary" : "Alternate"}}</button>

Upvotes: 3

Shashank Agrawal
Shashank Agrawal

Reputation: 25807

Here you go:

<button>{{action ? 'Signing in...' : 'Sign in'}}</button>

Upvotes: 2

Related Questions