所以我有一个用户的品牌控制器,它有2个变量 - user_brands,remaining_brands。 User_brands是用户最喜欢的品牌,remaining_brands是用户可能喜欢的品牌。
user_brands: function(){
var self = this, brands;
Ember.$.ajax({
type: 'GET',
url: '/user_favourites',
success: function(response){
brands = response["brands"];
},
error: function(error){
console.log('ERROR: ' + error);
}
});
return brands;
}.property('user_brands'),
remaining_brands: function(){
var self = this, remaining_brands;
Ember.$.ajax({
type: 'GET',
url: '/brands',
success: function(response){
console.log(self.get('user_brands')); //trying to reference user_brands defined above
remaining_brands = response["brands"];
},
error: function(error){
console.log('ERROR: ' + error);
}
});
return remaining_brands;
}.property('remaining_brands')
因此,为了获得剩余品牌',我试图让每个品牌都成为可能并通过“用户品牌”来减去它。如果用户已添加品牌,则不会显示重复项。如何正确引用user_brands函数?