1 . Use of the Select drop-down list box:
<select ng-model= "selected" ng-options= "User.ID as User.Name for user in users | By: ' Age ' ></select>
① Add a "Ng-model" directive that represents a drop-down box-bound entity object
② Add "ng-options" directives, the form of four types of directives:
1) Model.text for model in array;
2) Mode.value as Model.text for model in array;
3) Model.text Grou by group for model in array;
4) Model.value as Model.text Group by group to model in array;
The Model.value in ② and ④ above are the value values for each item in the drop-down list, which can be bound to a property of an element in an array, or directly to a single element object in an array.
That is, mode as Model.text for the model in array;
③ sets the default check for the drop-down box, selected=users[0].id
2, Services (service)
There are a number of ways to create a service:Factory,service,Provider,Decorator , Constant , Value
Introduces several common creation service methods: ①Factory ②service ③Provider
1. Factory can create multiple services, then inject the Factory name into the Controller and use the Factory object to obtain a specific service object.
2, service only create a specific service, and then injected into the Controller to use.
3, Provider provides a specific service + service configuration information. By specifying the configuration information for a service, a variety of representations of a service are implemented to fit a variety of requirements.
The code for each service creation is as follows:
①factory
app.factory ("MyFactory", function () { var services=// // //...}; return // returns all services (Factory mode)})
②service
app.service ("MyService", function () { var// specific service return // return to a specific service })
③provider
app.factory ("MyProvider", function () { var provider=// service // configuration Information }; return // returns all service and configuration information (configured to let service perform different results)})
When called, modify the configuration:
App. Config (function (myproviderprovider) {// Modify Configuration });
ANGULARJS Study Note One