ANGULARJS Study Note One

Source: Internet
Author: User

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

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.