May 08, 2021 AngularJS
AngularJS extends HTML with a new property called the directive.
The AngularJS directive is an extended HTML property with the prefix ng- .
The ng-app instruction initializes an AngularJS application.
The ng-init instruction initializes application data.
The ng-model directive binds element values, such as those of an input field, to an application.
The ng-app directive tells AngularJS that the element is the "owner" of the AngularJS application.
A Web page can contain multiple AngularJS applications running in different elements.
|
The expression in the instance above, the firstName, is an AngularJS data binding expression.
Data binding in AngularJS synchronizes the AngularJS expression with the AngularJS data.
The synchronization is done by ng-model, "firstName".
In the next instance, the two text fields are synchronized by two ng-model instructions:
Using ng-init is not very common. You'll learn a better way to initialize your data in the Controller chapter. |
The ng-repeat instruction repeats an HTML element:
The ng-repeat instruction is used on an array of objects:
AngularJS perfectly supports the database's CRUD (Add Create, Read Read, Update Update, Delete Delete) application.
Think of objects in an instance as records in a database. |
The ng-app directive defines the root element of the AngularJS application.
The ng-app instruction automatically boots (auto initializes) the application when the page loads.
You'll learn later how ng-apps connect to code modules with a value, such as ng-app "myModule."
The ng-init directive defines the initial value for the AngularJS application.
Typically, ng-init is not used. You will use a controller or module instead of it.
You'll learn more about controllers and modules later.
The ng-model directive binds HTML elements to application data.
The ng-model instruction can also:
The ng-repeat directive clones HTML elements once for each item in the collection (in the array).