0
問題は、私はset
メソッドにアクセスするためにできないことです。
this.$get = function($http) {
return
{
set: function(UserData)
{
this.user = UserData ;
localStorage.setItem('user', JSON.stringify(UserData));
},
get: function()
{
return this.user;
},
send: function(data)
{
$http.post(BASE_URL + 'user/login', data)
.then(function(res){
// Error !
this.set(res.data);
console.log(this); // return window object
// Here i want to access to 'this.set()'
// but i get error: 'ypeError: this.set is not a function'
});
}
}
}
私はthis.set()
おかげにアクセスするためのソリューションを検索します!
はなぜポストの前に変数右に「この」を代入しようとしないで、その後、コールバックでその変数を使用します。 – ronster37