我有,我想縮短,並使其更加簡單,因爲我不擅長用JavaScript我不斷收到錯誤,當我試圖縮短這樣的功能:的Javascript縮短和concatinating功能
$scope.doRefresh = function(){
if($scope.bulletpointPopular){
ArticleService.popular().then(function(data){
$scope.articles = data;
})
.finally(function() {
$scope.$broadcast('scroll.refreshComplete');
});
}
else {
ArticleService.all().then(function(data){
$scope.articles = data;
})
.finally(function() {
$scope.$broadcast('scroll.refreshComplete');
});
}
};
要這樣的:
$scope.doRefresh = function(){
if($scope.bulletpointPopular){
$scope.popular();
}
else {
$scope.latest();
}
.finally(function() {
$scope.$broadcast('scroll.refreshComplete');
});
};
Erorr:
Uncaught SyntaxError: Unexpected token .
你做了什麼錯誤?你忘了提及 – Ved