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
Post a Comment