ngStorage app showing the error [$injector:unpr] Unknown provider: $localStorageProvider <- $localStorage

4,835 views
Skip to first unread message

Chetan Patil

unread,
May 21, 2014, 3:48:04 AM5/21/14
to ang...@googlegroups.com
I am getting the error as i execute the page , when i adding the ngStorage to the anguglar module , Please guide me on this error . Please check below code for controller.js and index.html file 


Error: [$injector:unpr] Unknown provider: $localStorageProvider <- $localStorage http://errors.angularjs.org/1.2.7/$injector/unpr?p0=%24localStorageProvider%20%3C-%20%24localStorage at http://localhost/meritage/app/js/angular_1.2.7.js:78:12 at http://localhost/meritage/app/js/angular_1.2.7.js:3540:19 at Object.getService [as get] (http://localhost/meritage/app/js/angular_1.2.7.js:3667:39) at http://localhost/meritage/app/js/angular_1.2.7.js:3545:45 at getService (http://localhost/meritage/app/js/angular_1.2.7.js:3667:39) at invoke (http://localhost/meritage/app/js/angular_1.2.7.js:3694:13) at Object.instantiate (http://localhost/meritage/app/js/angular_1.2.7.js:3715:23) at http://localhost/meritage/app/js/angular_1.2.7.js:6766:28 at http://localhost/meritage/app/js/angular_1.2.7.js:6179:34 at forEach (http://localhost/meritage/app/js/angular_1.2.7.js:309:20) <div class="wrapper ng-scope" ng-view="">



----------------------------------------------------------------------------------------------------------------------------
Index.html file code is , I am include the the js/api/localStorage.js file in the index.html file  .

<!doctype html>
<html lang="en"  ng-app="myApp" ng-controller='MainCtrl'>
<head>
<meta charset="utf-8">
<title>My AngularJS App</title>
<!--   <script type="text/javascript" src="js/Lib/angular.min.js"></script> -->
<!-- <script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route_1.2.7.js"></script> -->

<script src="js/angular_1.2.7.js"></script>
<script src="js/angular-route_1.2.7.js"></script>
<script type="text/javascript" src="js/api/localstorage.js"></script>

<!-- <script type="text/javascript" src="js/Lib/angular.min.js"></script> 
<script type="text/javascript" src="js/Lib/angular-resource.min.js"></script>  -->

<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css" />
<link rel="stylesheet" type="text/css" href="css/jquery.mCustomScrollbar.css" />
<link rel="stylesheet" href="css/jquery-ui.css">
<script src="js/jquery-1.10.2.js"></script>
<script src="js/jquery-ui.js"></script>
<script src="js/jQuery.js"></script>
<script src="js/script.js"></script>

<script src="js/script.js"></script>
<link rel="stylesheet" href="css/app.css"/>


<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
<script src="js/filters.js"></script>
<script src="js/nav-left.js"></script>
<script src="js/directives.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.13.custom.min.js"></script>
<script type="text/javascript" src="js/jquery.multi-open-accordion-1.5.3.min.js"></script>
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.8.2/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="http://tablesorter.com/__jquery.tablesorter.min.js"></script>
<script src="js/jquery.mCustomScrollbar.js"></script>

<!-- datatable -->
<!-- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> 
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>  

 -->
<!-- datatable end -->
</head>
<body style="-webkit-app-region:drag;">

<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade
    your browser</a> to improve your experience.</p>
<![endif]--> 

<script src="bower_components/es5-shim/es5-shim.js"></script> 
<script src="bower_components/json3/lib/json3.min.js"></script> 

<!-- Add your site or application content here --> 
<!-- <div class="wrapper"  ng-controller="MyCtrl1"> </div> -->
<div ng-include="pageCtx.headerUrl"></div>
<h1>{{ pageCtx.title }}</h1>
<div ng-include="pageCtx.leftUrl"></div>
<div class="wrapper"  ng-view></div>
<div ng-include="pageCtx.footerUrl"> 
  <!--</div>-->
  <div>Angular seed app: v<span app-version></span></div>
</div>
</body>
</html>

------------------------------------------------------------------------------------------------------------------------------------------
Controller file code is i.e controller.js (full file code is not here ,just showing the function applied).

var myApp = angular.module('myApp', ['ngRoute'],['ngStorage']);


myApp.controller('loginsubmit',  function ($scope, $localStorage ){



        $scope.submit=function(){
          
            console.log( $scope.username +'---'+ $scope.password );


            Login.loginfunc( $scope.username ,$scope.password).then(function (response){

                        $scope.tokengenerated = response.data.token; 
                       
           
                  
            });

        }

});






Emmanuel DEMEY

unread,
May 21, 2014, 3:58:10 AM5/21/14
to ang...@googlegroups.com

Hi

I think you need to hasmve this :

angular.module('myApp', ['ngRoute', 'ngStorage']);

Instead of

var myApp = angular.module('myApp', ['ngRoute'],['ngStorage']);

Manu

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages