AngularJs(ngResource):错误:[$喷油器:modulerr] http://errors.angularjs.org/1.3.15/ [英] AngularJs (ngResource ) : Error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/
问题描述
我想用ngResource与HTTP,但我有此错误:
I want to use ngResource with HTTP but i have this error :
错误:[$喷油器:modulerr]
的http://errors.angularjs.org/1.3.15/$injector/modulerr?p0=myApp&p1=%5B%24injector%3Anomod%5D%20
Error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/$injector/modulerr?p0=myApp&p1=%5B%24injector%3Anomod%5D%20
下面是我的code:
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Angular ngResource</title>
<script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-resource.min.js"></script>
<script>
var myApp = angular.module('myApp', ['ngResource']);
myApp.factory('UserService',['$resource', function ($resource) {
return $resource('http://jsonplaceholder.typicode.com/users/:user',{user: "@user"});
}]);
myApp.controller('produitsCtrl', function($scope, $http,UserService) {
$scope.users = UserService.query();
});
</script>
</head>
<body>
<div ng-app="myApp" >
<div ng-controller="produitsCtrl">
<ul>
<li ng-repeat="x in users">
{{ x.name + ', ' + x.username }}
</li>
</ul>
</div>
</div>
</body>
</html>
和我的JSON文件是: HTTP://jsonplaceholder.typi$c$c .COM /用户
and my json file is : http://jsonplaceholder.typicode.com/users
[
{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere@april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
},
"phone": "1-770-736-8031 x56442",
"website": "hildegard.org",
"company": {
"name": "Romaguera-Crona",
"catchPhrase": "Multi-layered client-server neural-net",
"bs": "harness real-time e-markets"
}
},
{
"id": 2,
"name": "Ervin Howell",
"username": "Antonette",
"email": "Shanna@melissa.tv",
"address": {
"street": "Victor Plains",
"suite": "Suite 879",
"city": "Wisokyburgh",
"zipcode": "90566-7771",
"geo": {
"lat": "-43.9509",
"lng": "-34.4618"
}
}
]
任何一个有AN想法,请?
ANY ONE HAVE AN IDEA PLEASE ?
推荐答案
在 ngRessource
错字它应该是 ngResource
var myApp = angular.module('myApp', ['ngResource']);
你也做角JS 剧本
引用自动关闭这是完全错误的。你应该正确地关闭角的脚本。看看下面的。
Also You made angular js script
reference self closing which was totally wrong. you should close angular script tag properly. Look below.
<script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js">
</script>
这篇关于AngularJs(ngResource):错误:[$喷油器:modulerr] http://errors.angularjs.org/1.3.15/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!