码迷,mamicode.com
首页 > 其他好文 > 详细

angular ng-repeat

时间:2015-04-23 10:49:16      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:

in angular 1.3.0 u have to do like below, Because Global controllers were disabled in 1.3.0-beta.reference


<div id="tableAFS" ng-app="myApp" ng-controller="personController">
<table class="allDiv" ng-repeat="item in items">

<td>{{$index + 1}}</td>
<td>{{item.name}}</td>
<td>{{item.price | currency}}</td>
<td><input ng-model="item.quantity"></td>
<td>{{item.quantity * item.price | currency}}</td>
<td>
<button ng-click="remove($index)">Remove</button>
</td>

 

</table>

 

<script>
var app = angular.module("myApp",[]);

app.controller(‘personController‘, function($scope){
$scope.firstName = "David";

$scope.lastName = "Silva";

$scope.items = [

{ name: "雷柏(Rapoo) V500 机械游戏键盘 机械黄轴", quantity: 1, price: 199.00 },
{ name: "雷柏(Rapoo) V20 光学游戏鼠标 黑色烈焰版", quantity: 1, price: 139.00 },
{ name: "AngularJS权威教程", quantity: 2, price: 84.20 }
];

})
</script>

 

It also said that you can get the older behavior by using below code , but its not recomended

<div ng-app="myApp" ng-controller="personController">

var app = angular.module("myApp",[]).config([‘$controllerProvider‘, function($controllerProvider) {
$controllerProvider.allowGlobals();
}]);

function personController($scope) {
$scope.firstName = "David";
$scope.lastName = "Silva";
}

angular ng-repeat

标签:

原文地址:http://www.cnblogs.com/sonage/p/4449664.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!