現在出現了一個問題,我先擺出來:一個Price對象的getPriceUnderway方法,只會返回一個對象或者null,在測試函數內部的數據,沒問題;但是在另一個Controller.js裏面調用時,這個方法返回了undefined,還沒搞清楚緣由,代碼如下————
Price.getPriceUnderway = function(){
var activities = Activity.getActivities();
_.each(activities,function(ele){
var item = JSON.parse(localStorage.getItem(ele + '_price')) || [];//But this is a Array.Array
if(item.length != 0){
if(item[item.length - 1].price_state == Price.state_set.starting){
return item.pop();
}
}
return null;
});
}