javascript - Unknown provider: ngStorageProvider <- ngStorage when trying to use Angular ngStorage -


i have code below uses ngstorage. when try run part of angular app error console:

error: [$injector:unpr] unknown provider: ngstorageprovider <- ngstorage <- signupcontroller 

why?

sign in controller.js

var smalltalkzmodel = angular.module('smalltalkzmodel', ['ui.router', 'luegg.directives', 'ngcookies', 'ngstorage', 'angular-jwt']);  smalltalkzmodel.controller('signupcontroller', ['$scope', '$location', '$http', 'userdetails','ngstorage',     function ($scope, $location, $http, userdetails,$localstorage) {          $scope.register_user = function (info) {             $http({                 url: '/register_user',                 method: 'post',                 data: info             }).then(function (response) {                 $localstorage.jwt = response.data.id_token;                 $location.path('main');             }, function (error) {                 alert(error.data);             });         }     }]); 

update:

changed code include $localstoragein controller paramters. error mesge gone, $localstorage undefined after make assigmnet it...

controller('signupcontroller', ['$scope', '$location', '$http', 'userdetails', '$localstorage',     function ($scope, $location, $http, userdetails, $localstorage) {          $scope.login_info = "";         $scope.userdetails = userdetails.islogged;         $scope.userlogin = false;         $http.get('/online_users')             .success(function (data) {                 $scope.usersnumber = data.length;             })             .error(function (data) {                 console.log('error: ' + data);             });          $scope.register_user = function (info) {             $http({                 url: '/register_user',                 method: 'post',                 data: info             }).then(function (response) {                 $localstorage.jwt = response.data.id_token;                 $location.path('main');             }, function (error) {                 alert(error.data);             });         }      }]); 

this code throw error of undefined localstorage:

maincontroller.js

smalltalkzmodel.controller('maincontroller', ['$scope', 'sessioninfo', '$location', '$http', 'userdetails','$localstorage',     function ($scope, sessioninfo, $location, $http, userdetails, jwthelper,$localstorage) {          $scope.login_info = "";         $scope.userlogin = userdetails.islogged;          var jwt = $localstorage.jwt; // here $localstorage undefined ..........  } 

you need install ngstorage, , add project. not part of angular core.

if have installed, error caused because forgot add script in project.

here official documentation: https://github.com/gsklee/ngstorage

here example: how use ngstorage in angularjs

update:

i see in controller signupcontroller injecting ngstorage (in string part) when injection should $localstorage or $sessionstorage. causing issue because ngstorage module, not provider.

update 2:

when declaring maincontroller, second parameter modules controller depends on, there, forgot add string jwthelper, before string $localstorage. there 1 string less variables have in function.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -