angularjs is a high-end front-end mvc development framework developed by Google.
Angularjs official website: https://angularjs.org/ The official website has a demo, access may require FQ
Angularjs Chinese community: http://www.angularjs.cn/ Suitable for beginners
Reference file: https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js
Be careful when using angular
Quote the angularjs library: https://github.com/litengdesign/angularjsTest/blob/master/angular-1.0.1.... You can download it from the github of the examples in this section
You need to add ng-app="appName" in the area you are using, or directly ng-app (global).
Set controller ng-controller="Ctrl".
Please note the following points when testing the example
You need to introduce angularjs code before head. The author uses angular-1.0.1.min.js. Please pay attention to the version difference.
All small examples are run in the following areas. Remember to add ng-app in the scope.
The following uses some small cases to illustrate the default common instructions and usage of angularjs.
hello world program (double data binding)
Use ng-model={{name}} to bind data
http://2.liteng.sinaapp.com/angularjsTest/helloangularjs.html
A small case of using event binding
http://2.liteng.sinaapp.com/angularjsTest/event-bind.html
ng-init: attribute values can be specified by default
{{value}}
http://2.liteng.sinaapp.com/angularjsTest/ng-init.html
ng-repeat: used to iterate data similar to i for info in js
I have {{friends.length}} friends. They are
http://2.liteng.sinaapp.com/angularjsTest/ng-repeat.html
ng-click:dom click event
http://2.liteng.sinaapp.com/angularjsTest/ng-click.html
ng-show: Set element display
Note: ng-show="!xx": Add in front of the attribute value! Indicates confirmation of display, if not added! If unsure, do not display
http://2.liteng.sinaapp.com/angularjsTest/ng-show.html
ng-hide: Set element to hide
http://2.liteng.sinaapp.com/angularjsTest/ng-hide.html
Use ng-show to create toggle effect
http://2.liteng.sinaapp.com/angularjsTest/ng-toggle.html
ng-style: similar to the default style
Please pay attention to the writing format here: the string needs to be enclosed in quotes
filter: filter field
http://2.liteng.sinaapp.com/angularjsTest/filter.html
ng-template: Template can be loaded
tpl.html
$http: An ajax-like method works well
All the above codes: https://github.com/litengdesign/angularjsTest
Demo implemented: http://2.liteng.sinaapp.com/angularjsTest/index.html
As for the routing (router) and directive (directive) of angularjs, I will talk about them separately next time.