Raj Adroit Raj Adroit - 5 months ago 27
Javascript Question

Angular ui-router Resolve defining multiple methods

I'm chaning my initial service loading from controller to router resolve itself.
I tried like below, its working for calling single resolve method, if i try to call two methods, its showing syntax error. i google, i'm not getting exact syntax for this.

SyntaxError: missing } after property list

.state('my-order-list', {
url: '/my-order-list',
templateUrl: 'app/product/my-order-list.html',
controller: 'MyOrderListController',
controllerAs: 'vm',
resolve: {
orders: getUserOrders,
verifyToken: verifyToken
}
})


Methods are here

function getUserOrders(myOrderListService, $auth) {
return myOrderListService.getMyOrders($auth.getPayload().id);
}

function verifyToken($stateParams, userProfileService){
return userProfileService.verifyToken($stateParams.token);
}


I also tried separating two method's by curly braces, then also its not working..

Problem only when am calling more than one method, its working for calling one method.

Thanks in advance..

Answer

Used extra brace in the router definition, that's problem. Now working fine.. Thanks

.state('my-order-list', {
url: '/my-order-list',
templateUrl: 'app/product/my-order-list.html',
controller: 'MyOrderListController',
controllerAs: 'vm',
resolve: {
  orders: getUserOrders,
  verifyToken: verifyToken
}
}  << here i used unwated extra brace
})