How to set default value for scope variable in angularjs

raju

I currently display a scope variable using the following code

<a data-ng-href="#!/params/{{first.second.status}}">{{first.second.status}}</a>

Sometimes first.second.status is null, undefined or empty in which case I want to display "None" instead of actual value(empty)

One of the way to achieve the above is to put the check for the value of first.second.status in the controller and change its value accordingly but is there a more elegant way of doing it?

Eric

You could do:

<a ng-if="first.second.status" 
   data-ng-href="#!/params/{{first.second.status}}">{{first.second.status}}</a>
<span ng-if="!first.second.status">None</span>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to set a default value in an AngularJS Directive Scope?

From Dev

How to set scope variable value in angularjs template

From Dev

How to set scope variable value in angularjs template

From Dev

How to update $scope variable value in AngularJs

From Dev

how to set dropdown default value using angularjs

From Dev

Angularjs how to set the default value for select

From Dev

How to set default decimal value to input in angularjs

From Dev

How to set default value for select in angularjs

From Dev

default value of variable in angularjs

From Dev

PHP how set default value to a variable in the class?

From Dev

How to set the default value of a variable as an array?

From Dev

How to set the default value of enum type variable?

From Dev

PHP how set default value to a variable in the class?

From Dev

How is the default TERM shell variable value set?

From Dev

AngularJS / CSS - How to set the width of a select box to a value from $scope?

From Dev

Set default Value select AngularJS

From Dev

Set default value for select in angularjs

From Dev

How do I set default value of select box in angularjs

From Dev

How to set date and time as a default value in angularjs form field

From Dev

AngularJS: How to set default value to ng-model="searchText"?

From Dev

How to set default value from int on Angularjs <select>

From Dev

How to set default value checked in a checkbox from database using AngularJS

From Dev

How to set default value from int on Angularjs <select>

From Dev

How to set default selected value in select control in Angularjs?

From Dev

Set default value of a variable in PHP

From Dev

Get dynamic scope array variable value in angularjs

From Dev

Get dynamic scope variable value angularjs

From Dev

Get dynamic scope array variable value in angularjs

From Dev

How to bind a $scope variable to a normal variable in AngularJS?

Related Related

  1. 1

    How to set a default value in an AngularJS Directive Scope?

  2. 2

    How to set scope variable value in angularjs template

  3. 3

    How to set scope variable value in angularjs template

  4. 4

    How to update $scope variable value in AngularJs

  5. 5

    how to set dropdown default value using angularjs

  6. 6

    Angularjs how to set the default value for select

  7. 7

    How to set default decimal value to input in angularjs

  8. 8

    How to set default value for select in angularjs

  9. 9

    default value of variable in angularjs

  10. 10

    PHP how set default value to a variable in the class?

  11. 11

    How to set the default value of a variable as an array?

  12. 12

    How to set the default value of enum type variable?

  13. 13

    PHP how set default value to a variable in the class?

  14. 14

    How is the default TERM shell variable value set?

  15. 15

    AngularJS / CSS - How to set the width of a select box to a value from $scope?

  16. 16

    Set default Value select AngularJS

  17. 17

    Set default value for select in angularjs

  18. 18

    How do I set default value of select box in angularjs

  19. 19

    How to set date and time as a default value in angularjs form field

  20. 20

    AngularJS: How to set default value to ng-model="searchText"?

  21. 21

    How to set default value from int on Angularjs <select>

  22. 22

    How to set default value checked in a checkbox from database using AngularJS

  23. 23

    How to set default value from int on Angularjs <select>

  24. 24

    How to set default selected value in select control in Angularjs?

  25. 25

    Set default value of a variable in PHP

  26. 26

    Get dynamic scope array variable value in angularjs

  27. 27

    Get dynamic scope variable value angularjs

  28. 28

    Get dynamic scope array variable value in angularjs

  29. 29

    How to bind a $scope variable to a normal variable in AngularJS?

HotTag

Archive