Sort out some common commands in AngularJS: AngularJS

Source: Internet
Author: User
This article mainly introduces some common commands in AngularJS, including ng-app, ng-init, ng-model, and ng-repeat, for more information about HTML extensions, see AngularJS commands. These are all special attributes starting with the ng-prefix. We will discuss the following commands:

  • Ng-app-this command starts an AngularJS application.
  • Ng-init-this command initializes application data.
  • Ng-model-the model defined by this directive, which is used by variables in AngularJS.
  • Ng-repeat-this command repeats the HTML elements of each project in the set.

Ng-app command

The ng-app command starts an AngularJS application. It defines the root element. It automatically initializes or starts applications that load web pages containing AngularJS applications. It is also used to load AngularJS applications of various AngularJS modules. In the following example, the default AngularJS application uses the ng-app attribute of the p element.

...

Ng-init command

The ng-init command initializes the data of an AngularJS application. It is used to set the variables used in the application. In the following example, the countries array is initialized. Use the JSON syntax to define the countries array.

...

Ng-model command

The ng-model command defines the model/variable used in AngularJS applications. In the following example, we define a model named "name.

...

Enter your Name:

Ng-repeat command

The ng-repeat command repeats every item in the html element set. In the example below, we have iterated the array countries.

...

List of Countries with locale:

  1. {{ 'Country: ' + country.name + ', Locale: ' + country.locale }}

Example

The following example shows all the preceding commands.
TestAngularJS.html

AngularJS DirectivesSample Application

Enter your Name:

Hello!

List of Countries with locale:

  1. {'Country: '+ Country. name +', Locale: '+ country. locale }}

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.