AngularJs (ngResource ) : Error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/ -
i want use ngresource http have error :
error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/$injector/modulerr?p0=myapp&p1=%5b%24injector%3anomod%5d%20
here 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>
and json file : 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" } } ]
any 1 have idea please ?
typo in ngressource
should ngresource
var myapp = angular.module('myapp', ['ngresource']);
also made angular js script
reference self closing totally wrong. should close angular script tag properly. below.
<script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"> </script>
Comments
Post a Comment