ng-app ng-control ng-model ng-click 等等
==============
var app = angular.module('app',[]);
app.controller('MainCtrl',function($scope) {$scope.greet = function() {
$scope.message = "Hello," + $scope.user.name;
}
});
<body ng-app="app" ng-controller="MainCtrl">
What's your name?:
<input type="text" ng-model="user.name" />
<button ng-click="greet()">Click here!</button>
<h3>{{ message }}</h3>
</body>
==========html tag补充例如pie-chart
<body>
<pie-chart width="400" height="400" data="data"></pie-chart>
</body>
===这个变量必须声明的啊?show=!show,直接每次改变boolean
<button ng-click="show = !show">Show</button>
<div ng-show="show">
I am only visible when show is true. </div>
---<li ng-repeat="person in developers">
{{person.name}} from {{person.country}}
</li>
===这种看起来和任何其他的模版语言没啥差别,可以直接和变量交互
使用Service来进行变量交互
接下来需要借助services来解决这个问题,利用services将user name在controller之间共享。 service==userinformation,函数是初始化函数 app.factory('UserInformation',function() { var user = { name: "Angular.js" }; return user; });
原文链接:/angularjs/149048.html