Angularjs 未捕获错误:[$injector:modulerr]角度为1.3
我是angular.js的新手,我尝试使用angular.js 1.3.2开发一个小应用程序。我得到了这个错误,我不明白。为什么会发生这种错误 index.htmlAngularjs 未捕获错误:[$injector:modulerr]角度为1.3,angularjs,Angularjs,我是angular.js的新手,我尝试使用angular.js 1.3.2开发一个小应用程序。我得到了这个错误,我不明白。为什么会发生这种错误 index.html <!DOCTYPE html> <html ng-app='store'> <body> <script type="text/javascript" src="angular.min.js"> </script>
<!DOCTYPE html>
<html ng-app='store'>
<body>
<script type="text/javascript" src="angular.min.js">
</script>
<script type="text/javascript" src="app.js">
</script>
<div ng-controller="StoreController">
<h1>
{{StoreController.product.title}}
</h1>
</div>
</body>
</html>
未捕获错误:[$injector:moduler]http://errors.angularjs.org/1.3.2/$injector/modulerr?p0=store&p1=Error%3A%2…F%2Fhome%2Fnaveed%2FDocuments%2Fwork%2Fangular%2Fangular.min.js%3A17%3A381)angular.js:4020是否需要将$scope变量绑定到视图
<h1>
{{product.title}}
</h1>
您忘记调用app.js中的匿名函数:
(函数{…}())代码>我认为它是(函数(){}();这两件作品都是D.Crockford推荐的,而不是你的,请看。实际上,在我之前,我在结尾加了括号。Nw我没有收到错误,但它没有显示结果,即加载的html页面为空。嗨,elite。。。。写入$scope不是强制性的。。。
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.2/$injector/modulerr?p0=store&p1=Error%3A%2…F%2Fhome%2Fnaveed%2FDocuments%2Fwork%2Fangular%2Fangular.min.js%3A17%3A381) angular.js:4020
<h1>
{{product.title}}
</h1>
(function(){
var app = angular.module('store', []);
app.controller('StoreController', function($scope){
var gem = {
title: "hello",
description: "nnothing gr8"
}
$scope.product = gem;
});
})(); // your function needs to be run
(function(){
var app = angular.module('store',[]);
app.controller('StoreController', ['$scope', function($scope) {
$scope.product = gem;
}]);
var gem={
title: "hello",
description: "nothing gr8"
}
})();