ANGULARJS Learning 1-Basic knowledge

Source: Internet
Author: User

In fact, a relatively hindsight knowledge, with the NG basis to see this will have a deeper understanding, but not suitable for getting started.

The AngularJS application consists of the following:

View, which is HTML.

Model (models), the data available in the current view.
Controller, the JavaScript function, can add or modify properties.

Scope is a model and a link between view and controller.

It's all annotated with//. Because you can't use shortcut keys.

Give an example

Using JS, basically just need to focus on the body inside the things just fine

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Scriptsrc= "Https://cdn.bootcss.com/angular.js/1.4.6/angular.min.js"></Script></Head><Body>//Declare this app is MyApp, controller is Personctrl<DivNg-app= "MYAPP"Ng-controller= "Personctrl">//ng-model is actually declaring a variable, two-way binding, as long as the value of the variable is changed, the place to use this variable will immediately change the name:<inputtype= "text"Ng-model= "FirstName"><BR>Surname:<inputtype= "text"Ng-model= "LastName"><BR><BR>//Use the method name defined inside the controller: {{fullName ()}}</Div>//In the controller, define some actions through scope<Script>varapp=Angular.module ('myApp', []); App.controller ('Personctrl', function($scope) {//This is just the initialized value, so you don't need any ng-init.$scope. FirstName= "John"; $scope. LastName= "Doe"; //declares a function$scope. FullName= function() {        return$scope. FirstName+ " " +$scope. LastName; }});</Script></Body></HTML

ANGULARJS Learning 1-Basic knowledge

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.