Looking for help to simplify and shorten a Javascript function:
$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');
});
}
};
Simplified version attempted:
$scope.doRefresh = function (){
if($scope.bulletpointPopular){
$scope.popular();
}
else {
$scope.latest();
}
.finally(function() {
$scope.$broadcast('scroll.refreshComplete');
});
};
Error message received:
Uncaught SyntaxError: Unexpected token .