AngularJS Study notes (ii)

Source: Internet
Author: User

there are ng-controller in Angularjs, which allows the DOM element to be mounted on a controller.

such as this:

<div ng-controller= "Firstcontroller" > <p ng-bind= "i" ></p> <input type= "text" ng-model= "abc" val Ue= "" > <p ng-bind= "abc" ></p> </div>

This means that the scope of the controller is the entire div, the contents of which are controlled by the controller named Firstcontroller. In this piece of code,

<p ng-bind= "I" ></p>

equivalent to {{i}}, but I this variable is not defined yet. So you define it in the controller:

<script type= "Text/javascript" >var Firstcontroller = function ($scope) {$scope. i = 0;} </script>

Firstcontroller as a function, $scope is its scope, note that $scope can not be changed to another variable name, which is dedicated.

<input type= "text" ng-model= "abc" value= "" >

It's actually equivalent to automatically adding a variable ABC to the Firstcontroller function.

Above is only the use of the Angularjs 1.2.x version, in the high version, This method is forbidden, because this way will let controller flying, the level of confusion, everything hangs in $ On the Rootscope.

<! doctype html>


This article is from the "Pomelo Juice Front End" blog, please make sure to keep this source http://iampomelo.blog.51cto.com/10193513/1658455

AngularJS Study notes (ii)

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.