javascript - AngularJS : Factory $http assigning values returning null -


i trying assign variable $http.get() though conf var null despite request going through , returning json.

app.factory('config', ['$http',     function($http) {         return {              conf: null,              init: function () {                  if (this.conf === null) {                     $http.get('/config')                         .success(function (data) {                             this.conf = data;                         });                 }             }         }     } ]); 

this inside success callback function different

app.factory('config', ['$http',     function($http) {         return {              conf: null,              init: function () {                 var self = this;                 if (this.conf === null) {                     $http.get('/config')                         .success(function (data) {                             self.conf = data;                         });                 }             }         }     } ]); 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -