Wednesday 15 September 2010

angularjs - Uncaught Error: [$injector:modulerr] in angular 1.3 -



angularjs - Uncaught Error: [$injector:modulerr] in angular 1.3 -

i'm new angular.js , tried develop little application using angular.js 1.3.2. getting error not understand. why error occurring?

index.html

<!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>

app.js

(function(){ var app = angular.module('store', []); app.controller('storecontroller', function(){ this.product = gem; }); var gem = { title: "hello", description: "nnothing gr8" } }); 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

shouldn't need $scope variables tied view?

<h1> {{product.title}} </h1>

so need inject $scope things working:

(function(){ var app = angular.module('store', []); app.controller('storecontroller', function($scope){ var gem = { title: "hello", description: "nnothing gr8" } $scope.product = gem; }); })(); // function needs run

angularjs

No comments:

Post a Comment