Pablo
Pablo

Reputation: 10612

Can I change label text in AngularJs Directly from view?

I have this code in my HTML

<span ng-class="newProvider ? 'newProvider' : ''" 
      class="help-block">
          {{ 'new-product.provider.helper' | locate }}
</span>

When newProvider is true, I need to load another text like

{{ 'new-product.provider.newProvider' | locate }}

Is there anyway I can do this check for the label content? And if not, how should I load this text in the controller?

Upvotes: 1

Views: 1599

Answers (1)

Ignacio Villaverde
Ignacio Villaverde

Reputation: 1264

You could define a watcher over newProvider and modify the text in the attached function.

Use $watch for this. Here is a plunker for you to see: http://plnkr.co/edit/BAtiGXaCDIqQdw86KJwE?p=preview

However, I would prefer using ng-show, ng-switch or ng-if

Upvotes: 1

Related Questions