Basic introduction and practice of AugularJS

巴扎黑
Release: 2017-07-23 11:33:37
Original
1311 people have browsed it

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 call
directives. (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】






1. AngularJS common instructions


【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:
1  2  3  4  5  6 13 
14 15 
16 17
18
19
20
21
22
23 24
25
26 27
28
29 30
31 32 33 34 53
Copy after login



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

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!