Giter Site home page Giter Site logo

控制器 about angular-tutorial HOT 1 OPEN

wscats avatar wscats commented on July 24, 2024
控制器

from angular-tutorial.

Comments (1)

Wscats avatar Wscats commented on July 24, 2024

1.ng-app指令定义一个AngularJS应用程序
var app = angular.module("angularDemo", []);

2.ng-controller指令定义了应用程序控制器,控制作用域

app.controller('studentCtrl', function($scope, $rootScope) {
//数据操作
})

解决压缩的一种写法,把他整个传回调函数的过程,改写成数组的形式存放

app.controller('studentCtrl', ['$scope', '$rootScope',function($scope, $rootScope) {
//数据操作
}])

3.$scope为控制器作用域、控制范围内生效的对象,只在所在的控制器生效
$scope.wsscat = 'a';
$scope也是应用在HTML(视图)和JavaScript(控制器)之间的纽带,实现单向绑定
HTML(视图)就可以用{{wsscat}}渲染数据

4.表达式的{{}}双大括号或者’ng-bind‘
把数据绑定到HTML(视图上)

{{a}}
<p ng-bind="a">

5.管道字符(|)给表达式{{}}添加过滤器
例如{{wsscat|uppercase}},{{money|currency:'&'}}

6.ng-model输入结果,并把结果传递给对应控制器中$scope
<input ng-model="wsscat" value="" />实现双向绑定

from angular-tutorial.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.