我是angularJS的新手,我从一本关于AngularJs的书中学到了很多东西。我尝试运行书中给出的一个例子,但我看不到内容。这是代码
<html ng-app="myApp">
<head>
<title> Shopping Cart </title>
</head>
<body np-controller='CartController'>
<h1>Your Order</h1>
<div ng-repeat='item in items'>
<span>{{item.title}}</span>
<input ng-model='item.quantity'>
<span>{{item.price | currency}}</span>
<span>{{item.price * item.quantity | currency}}</span>
<button ng-click="remove($index)">Remove</button>
</div>
<script src="angular.js"></script>
<script>
var app = angular.module('myApp',[]);
app.controller('CartController',function ($scope){
$scope.items = [
{
title: 'Paint Pots',
quantity: 8,
price: 3.95
},
{
title: 'Polka Dots',
quantity: 17,
price: 12.95
},
{
title: 'Pebbles',
quantity: 6,
price: 6.95
}
];
$scope.remove = function(index){
$scope.items.splice(index,1);
}
})
</script>
</body>
</html>
但是当我在浏览器中打开时,我看到的只是“你的订单”,其余的都是空白的。我检查了控制台,但它没有错误。任何人都可以帮我解决这个问题吗?
答案 0 :(得分:0)
错字
ng-controller
而不是
np-controller