Angularjs is a Google project that makes up for HML's lack of construction and extends HTML tags through directives (directive), allowing developers to use HTML to declare dynamic content.
Angularjs is mainly used to develop a single page application (SPA)-based project.
Angularjs four main features: 1.MVC mode 2. Bidirectional data binding 3. Modular 4. Instruction System
in order to use angular, all applications must do two things first1.Download load angular.js library2.Use the Ng-app directive to tell angular which parts of the DOM should be managed。 Some common directives in angular: Ng-app: root element in Web page, Ng-init: Initialize data; Ng-bind: Bind data; Ng-show: Show; Ng-hide: Hide Data ; Ng-class: Control Classng-click: Bind fixed-point event; ng-disabled: Disable event; Ng-model: Bind data in HTML; ng-repeat: cyclic data;
1. Angularjs MVC
Model : Data Model layer
View : views layer, responsible for showing
Controller: business logic and control logic
Advantages: Code Modular Code logic is clear, high-value-shifting, late maintenance, code reuse, code size is getting bigger, the role of segmentation is the trend
Cons: run a little less efficiently
$scope control scope; $rootscope: root scope, global scope;
1. Angularjs The $apply method inside the $scope $apply Method: Scope provides a $apply method for propagating model changes
$apply Method Usage Scenarios:$apply must be called after ANGULARJS external controllers (DOM events, external callback functions such as jquery UI space, etc.) have called the ANGULARJS function. In this case, you need to command Angularjs to refresh itself (model, view, etc.), $apply is used to do this thing.
$apply Method Considerations:As long as you can, pass the code and functions you want to execute to $apply, instead of executing those functions and then calling $apply. For example, you should execute your code as follows: $scope. $apply (function () {$scope. variable1 = ' some value '; Executesomeaction ();});
2. Angularjs The $watch method inside the $scope $watch method: The $watch method monitors the model changes.
Angularjs Simple Basics of learning notes