我正在嘗試使用角度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