'chrome' object is undefined in AngularJS $window service -


i developing chrome app angularjs. app uses chrome.storage created wrapper in order work it. code of wrapper looks this:

angular.module('myapp').factory('chromestorageapi', function ($window, $q) {   var deferred = $q.defer();    return {     set: function (obj) {       if ('chrome' in $window && typeof  $window.chrome.storage === 'undefined') {         return deferred.reject();       } else {         $window.chrome.storage.local.set(obj, function(){           if($window.chrome.runtime.lasterror !== 'undefined') {             return deferred.reject();           }           deferred.resolve();         });       }      ................ 

i have service ('storageservice') has wrapper dependency:

angular.module('myapp').factory('storageservice', function ($q, $rootscope, $http, chromestorageapi) { ....... 

the problem $window in storageservice has 'chrome' object , it's possible work chrome.storage there in wrapper 'chrome' object gets 'undefined'.

typeerror: 'undefined' not object (evaluating '$window.chrome.storage') 

i understanding why happens. in 1 place $window has 'chrome' object in 1 hasn't.

thanks.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -