我正在尝试使用角度js来创建一个页面,它给了我这个错误:Uncaught Error:[$ injector:modulerr] http://errors.angularjs.org/1.6.3/ $ injector/modulerr?p0 = store & p1 =错误%3A %2 ... F%2FC%3A%2FUsers%2Fhp%2FDesktop%2FAngular%2Fjs%2Fangular.min.js%3A22%3A179)Angular.js未被捕获的错误
这里是我的代码:
(function() {
var app = angular.module('store', ['ngRoute']);
app.controller('StoreController', function() {
this.products = gems;
});
var gems = [
{
name: 'Dodecahedron',
price: 2.95,
description: 'Some gems have hidden qualities beyond their luster, beyond their shine... Dodeca is one of those gems.',
canPurchase: true,
soldOut: true,
},
{
name: 'Pentagonal Gem',
price: 5.95,
description: 'Some gems have hidden qualities beyond their luster, beyond their shine... Dodeca is one of those gems.',
canPurchase: true,
soldOut: true,
},
];
});
<!DOCTYPE html>
<html ng-app="store">
<head>
<link rel="stylesheet" href="css/bootstrap.min.css"> </head>
<body ng-controller="StoreController as store">
<div ng-repeat="product in store.products">
<h1>{{product.name}}</h1>
<h2>${{product.price}}</h2>
<p>{{product.description}}</p>
<button ng-show="product.canPurchase">Add to cart</button>
</div>
<script src="js/angular.min.js"></script>
<script src="js/app.js"></script>
</body>
</html>
你在哪里将控制器绑定到视图?我无法在模板中看到任何ng控制器,也无法看到路由配置。 – Dario
其题外:“为什么我的代码不能运行..” – lin
@Dario我更新了这个问题,但它没有工作,要么它有相同的错误 – stephjhonny