Issue
I am a beginner in Angular.js, so I have decided to try a Google tutorial, and I just don't understand why this error keep occurring. I searched for the solution in Stack Overflow, and most of the people said to take off the"gemStore" in my ng-app, but I tried that too and it didn't work as well:
angular.js:38Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.6.1/$injector/modulerr?p0=gemStore&p1=Error%3…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.6.1%2Fangular.min.js%3A21%3A332)
at angular.js:38
at angular.js:4759
at q (angular.js:357)
at g (angular.js:4720)
at eb (angular.js:4642)
at c (angular.js:1838)
at Mc (angular.js:1859)
at pe (angular.js:1744)
at angular.js:32977
at HTMLDocument.b (angular.js:3314)
What can I do to fix it?
JS code:
(function() {
var app = angular.module('gemStore', []);
app.controller('StoreController', function() {
this.products = gems;
});
var gems = [{
name: 'Azurite',
description: "Some gems have hidden qualities beyond their luster, beyond their shine... Azurite is one of those gems.",
shine: 8,
price: 110.50,
rarity: 7,
color: '#CCC',
faces: 14,
images: [ ]
}, {
name: 'Bloodstone',
description: "Origin of the Bloodstone is unknown, hence its low value. It has a very high shine and 12 sides, however.",
shine: 9,
price: 22.90,
rarity: 6,
color: '#EEE',
faces: 12,
images: [
"images/gem-01.gif",
"images/gem-03.gif",
"images/gem-04.gif"
]
}, {
name: 'Zircon',
description: "Zircon is our most coveted and sought after gem. You will pay much to be the proud owner of this gorgeous and high shine gem.",
shine: 70,
price: 1100,
rarity: 2,
color: '#000',
faces: 6,
images: [
"images/gem-06.gif",
"images/gem-07.gif",
"images/gem-09.gif"
]
}];
})();
index.html code:
<!DOCTYPE html>
<html ng-app="gemStore">
<head>
<link rel="stylesheet" type="text/css" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script type="text/javascript" src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>
<script type="text/javascript" src="app.js"></script>
>
</head>
<body ng-controller="StoreController as store">
<!-- Products Container -->
<div class="list-group">
<!-- Product Container -->
<div class="list-group-item" ng-repeat="product in store.products">
<h3>
{{product.name}}
<em class="pull-right">{{product.price | currency}}</em>
</h3>
<!-- Image Gallery -->
<div ng-show="product.images.length" class="gallery">
<img class="img img-circle img-thumbnail center-block" ng-src="{{product.images[0]}}" />
<ul class="clearfix">
<li class="small-image pull-left thumbnail" ng-repeat="image in product.images"> <img ng-src="{{image}}" /> </li>
</ul>
</div>
</div>
</div>
</body>
</html>
Solution
There is no problem with parenthesis.
Your code just works, I tested it just now in Chrome and Firefox but you should avoid using single quote. Double quotes is considered standard while single quote is not. http://www.json.org/
Could you provide more information like the browser/version you're using ?
Open a Chrome tab in private mode without any chrome extension and check if it still fails.
Edit: Are you sure that the app.js file contains only the code mentioned above?
If not, please provide the full content of app.js
Answered By - Stephane Janicaud
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.