我是 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>
但是当我在浏览器中打开时,我看到的只是“您的订单”,其余部分都是空白。我检查了控制台,但没有错误。谁能帮我解决这个问题吗?
最佳答案
那里有错字
ng-controller
而不是
np-controller
关于javascript - 无法在浏览器上显示内容-AngularJS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48002004/