ANGULARJS Basic Syntax

Source: Internet
Author: User

1, Ng-app

Determines the scope of the ANGULARJS, which you can use as follows:

To let Angularjs render the entire page, or you can use the

<div ng-app= ' MyApp ' >......</div>

To render a portion of them.

2, Ng-model

Ng-model, when your data model is changed, such as ng-model= ' test ', where the value of this test is changed, the value of {{test}} will follow the change, that is, the test connected to Ng-model also follows the change, as follows

<!doctype html>
3, Angular.module

This is mainly to do the module registration, creation and indexing, for example, we ng-app want to register this as a service to use, when we reference the index of a module to use

Angular.module (name, [requires], [CONFIGFN]); The       name of the retrieval module created by the #name type string #requires   simple Understanding is the use module that you need to include, For example, Ngroute routing module #configfn   can be optional function module, function and Module.config similar
4. Controller

Controller is angular. The method controller (name, constructor) in module, where name is the name of the controller and constructor is the director constructor, we use a piece of code to illustrate

<!doctype html>
5. Value

Value is also angular. The method in module is value (name, object), where name is the name of the service, object is the server instance, and we can modify the code above

<!doctype html>
6, Factory

Factory is also angular. Method factory in module (name, providerfunction);; Where name is the name of the service, Providerfunction is the function used to create the new server object, and this is where we can modify the code above.

Copy the code code as follows:

<!doctype html>

Provider is also angular. The method in module provider (name, ProviderType), where name is the name of the service, Providerfunction is the function used to create a new server object, which is similar to factory, We're now rewriting it with provider.

Copy the code code as follows:

<!doctype html>

  

8. Service

Service is also angular. The method service (name, constructor) in module, where name is the name of the service, constructor a constructor to be instantiated, which is similar to factory, which we now rewrite with service

Copy the code code as follows:

<!doctype html>

  

9, Constant

Constant is also angular. The method in module constant (name, object), where name is the name of the constant, and object is the value of the constant, which we can write

Copy the code code as follows:

<!doctype html>

  

ANGULARJS Basic Syntax

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.