ng-Select Option set default value from list if value match using angularJS

Santosh

I have html.

<select  ng-model="user.role" class="form-control" name="role" >
    <option value="">Select Role</option><option ng-repeat="role in roles" value="{{role.authority}}">{{role.authority}}</option> </select>

Now roles is a list and role.authority is string. i want to set default selected if role.authority==MYROLE then set to default, which is in role.authority.

How can i do

maurycy

You have to assign the same value to select model inside controller, in your case it would be something like this

$scope.user.role = $scope.roles[0].authority

or with use of ngSelected

<option ng-repeat="role in roles" value="{{role.authority}}" ng-selected="role.authority == 'defaultValue'">{{role.authority}}</option>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

ng-Select Option set default value from list if value match using angularJS

From Dev

angularjs set default value ng-model using value from another ng-model

From Dev

AngularJS - ng-repeat default value for select option

From Java

how to use ng-option to set default value of select element

From Dev

set default option in a select via ng-init on VALUE and not INDEX

From Dev

how to set the value of an option when using ng-options in a select with angularjs

From Dev

AngularJS - Set default value on select inside a ng-repeat

From Dev

Angularjs - set the default value for select without ng-options

From Dev

Angularjs - set the default value for select without ng-options

From Dev

AngularJS set default <select> value from JSON model with ng-options

From Dev

Set default Value select AngularJS

From Dev

Set default value for select in angularjs

From Dev

The default value is not ? object:null ? in select option Angularjs

From Dev

Set default value of select to null option

From Dev

how to set a default value for select option

From Dev

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

From Dev

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

From Dev

using ng-options with angular to display select option with key and value and setting a default value

From Dev

Angularjs how to set the default value for select

From Dev

Unable to set default value on AngularJS select box

From Dev

Set a default value in a select with simple array in AngularJS

From Dev

How to set default value for select in angularjs

From Dev

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

From Dev

Insert a "Select Value" option in dropdown list from array using jQuery

From Dev

AngularJS - nested ng-repeat with select/option, get/set the selected value

From Dev

Set default value of dropdown list in angularjs materials

From Dev

Set default value in <select> with angular ng-options maybe using ng-init

From Dev

I cannot set default value in select list

From Dev

how to set dropdown default value using angularjs

Related Related

  1. 1

    ng-Select Option set default value from list if value match using angularJS

  2. 2

    angularjs set default value ng-model using value from another ng-model

  3. 3

    AngularJS - ng-repeat default value for select option

  4. 4

    how to use ng-option to set default value of select element

  5. 5

    set default option in a select via ng-init on VALUE and not INDEX

  6. 6

    how to set the value of an option when using ng-options in a select with angularjs

  7. 7

    AngularJS - Set default value on select inside a ng-repeat

  8. 8

    Angularjs - set the default value for select without ng-options

  9. 9

    Angularjs - set the default value for select without ng-options

  10. 10

    AngularJS set default <select> value from JSON model with ng-options

  11. 11

    Set default Value select AngularJS

  12. 12

    Set default value for select in angularjs

  13. 13

    The default value is not ? object:null ? in select option Angularjs

  14. 14

    Set default value of select to null option

  15. 15

    how to set a default value for select option

  16. 16

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

  17. 17

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

  18. 18

    using ng-options with angular to display select option with key and value and setting a default value

  19. 19

    Angularjs how to set the default value for select

  20. 20

    Unable to set default value on AngularJS select box

  21. 21

    Set a default value in a select with simple array in AngularJS

  22. 22

    How to set default value for select in angularjs

  23. 23

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

  24. 24

    Insert a "Select Value" option in dropdown list from array using jQuery

  25. 25

    AngularJS - nested ng-repeat with select/option, get/set the selected value

  26. 26

    Set default value of dropdown list in angularjs materials

  27. 27

    Set default value in <select> with angular ng-options maybe using ng-init

  28. 28

    I cannot set default value in select list

  29. 29

    how to set dropdown default value using angularjs

HotTag

Archive