gpt4 book ai didi

javascript - Uncaught Error : [$injector:modulerr] but not ng-route

转载 作者:行者123 更新时间:2023-11-28 18:40:18 25 4
gpt4 key购买 nike

我已经研究了几个与此相关的问题,但就我的一生而言,我无法弄清楚这个问题。我没有使用 ng-route ,并且我确信它会获取我正在尝试学习一些基本 js 的文件,所以我一直在做一些教程。其中之一抛出此错误:

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.10/$injector/modulerr?p0=gemStore&p1=Error%…gleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.3.10%2Fangular.min.js%3A17%3A350)

已编辑

这是我的代码:HTML

//index.html
<!doctype html>
<html ng-app="gemStore">
<head>
<title>myTestApp</title>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.10/angular.min.js"></script>
<script type="text/javascript" src="app.js" />
</head>
<body ng-controller="StoreController as store">
<div ng-repeat="product in store.products" ng-hide="store.product.soldOut">
<h1>{{store.product.name}}</h1>
<h1>{{store.product.price}}</h1>
<h1>{{store.product.desc}}</h1>
<button ng-show="store.product.canPurchase">Add To Cart</button>
</div>
</body>
</html>

Javascript:

    var app = angular.module('gemStore', []);
app.controller('StoreController', function() {
this.products = gems;
});
var gems = [
{
name: 'Gem',
price: 2.95,
desc: '. . .',
canPurchase = false,
soldOut = true,
},
{
name: 'Gem2',
price: 3.95,
desc: '. . .',
canPurchase = false,
soldOut = true,
}
]

最佳答案

这应该会让你非常接近。希望它有帮助:)

<html ng-app="gemStore">
<head>
<title>Angular JS</title>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.10/angular.min.js"></script>

</head>
<body>
<div ng-controller="StoreController">

<h1> {{products.name}} </h1>
<h1> {{products.price}} </h1>
<h1> {{products.desc}} </h1>
</div>
<script type="text/javascript" src="app.js"></script>
</body>
</html>

app.js

(function () {

var app = angular.module("gemStore", []);
app.controller('StoreController', ['$scope', function($scope) {
$scope.products = gem;
}]);
var gem =
{
name:'New Product',
price:'2.95',
desc: '...'
}
})();

关于javascript - Uncaught Error : [$injector:modulerr] but not ng-route,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36212182/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com