Foreword
## Front-end
AngularJS is designed to overcome the shortcomings of HTML in building applications. (Quote from Baidu Encyclopedia)
AngularJS uses a different approach. It tries to make up for the shortcomings of HTML itself in building applications. AngularJS enables browsers to recognize the new syntax by using structures we calldirectives. (Quote from Baidu Encyclopedia)For example:Use double curly brackets {{}} syntax for data binding ;
Use DOM control structures to iterate or hide DOM fragments;
Support forms and form validation;
wanted should be associated:
This study mainly has two parts: ①【AngularJS common instructions】②【AngularJS’s mvc】
【Common commands】 1.na-app: Declare the area governed by angularjs, usually written in the body or HTML. In principle, only write one on each side. #& Lt; body ng-apg = "" & gt; & lt;/body & gt; 2.ng-Model instructions bind the elemental value (such as the value of the input domain) to the application. not not have been more relevant? Since The ng-init directive initializes AngularJS application variables. Numbers, operators and variables. But the expression will see {{}} when the web page is loaded, so you can use ng-bind=" instead {{5+""+5+',Angular'}} [Basic Thoughts] Instructions: In AngularJS, functions are provided by extending the attributes of HTML ↓↓↓↓ (original words in the novice tutorial) AngularJS instructions are extended HTML Attributes with prefix NG-. The element value (such as the value of the input field) is bound to the application. mvc for AngularJS [mvc three-tier framework] 1. Model: the part of the application that handles attributes. (Save or modify data to database, variables, etc.). The characteristics of the Model in AugularJS are: data . Responsible for reading data from views, controlling user input, and sending data project-wide. 2. Working principle: The user sends a request from the view layer. After receiving the request, the controller forwards it to the corresponding model for processing. After the medle processing is completed, the result is returned to the controller and fed back to the user in the view.
Create an Angular module, that is, parts bound by NG-APP, you need to pass two parameters:
① the module name, that is, the name that Ng-APP needs to be bound to . ng-app="myApp"; ② Array: The name of the module that needs to be injected. It can be empty if not required. var app = Angular.module ("MyApp", []); On the Angular module, creating a controller Controller needs to pass two parameters. ① ng-controller="myCtrl" ② Controller's constructor: The constructor can pass in multiple parameters, including $scope/$roatScope and various system built-in objects Scope】 ①$scope: local scope, properties and methods declared on $scope can only be used in the current Controller; ②$rootScope: root scope, declared on $rootscope Familiarity and methods can be used in any area contained by ng-app (whether or not it agrees with the controller, or is in the controller's containing scope). # , then this variable will be bound to the $scope of the current Controller by default 2. If ng-model is not in any ng-controller, this variable will be bound to $rootScope.
The rendering is as follows:
![]()
##The code is as follows:
There may be some mistakes in the notes taken while studying. Your criticism and advice are welcome.
Reflect, review, and gain something every day------------------------looking forward to a better self
1 2 3 4 5
Copy after login
|
The above is the detailed content of Basic introduction and practice of AugularJS. For more information, please follow other related articles on the PHP Chinese website!