Angular the Select instruction usage detailed _ANGULARJS

Source: Internet
Author: User

There have been a lot of problems with the recent use of the Select command in angular, which is depressing. After looking at a lot of data, it was not easy to find the Select command, and decided to summarize.

  Select usage:

<select
ng-model= "
[name="]
[required= "]
[ng-required="]
[ng-options=
"]]> </select>

 Attribute Description:

Discovery and no Ng-change attribute

Ng-required: When the property value is true, add required validation to select, False when not validated.

Ng-options: Specifies the data source to generate option options.

 When a data source is an array, use:

Label for value in array
Select as label for value in array
Label GROUP by Group for value in array
Select as Label group by GROUPEXPR for value in array track by trackexpr

When the data source is an object, use:

Label for (key,value) in Object
Select as label for (Key,value) in Object
Label GROUP BY Group for (Key,value) in Object
Select as Label group by GROUPEXPR for (Key,value) into object track by trackexpr

Specific Description:

Array/object: Array/Object

The name displayed by the Label:option option.

Select: Is the value that is bound to Ngmodel after an item is selected.

Value: The values in the array.

(key,value): Key,value of objects.

GROUP BY groupexpr: for option grouping,

The difference between ng-options and ng-repeat automatically generates option options:

When the Ng-options option is selected, the value bound to Ngmodel can be an object. Ng-repeat bound to Ngmodel value can only be a string.

Note: You need to specify a value for Ngmodel when the select is initialized, otherwise a blank option appears.

The above is a small set of angular to introduce the select instructions in the use of detailed, hope to help everyone, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.