Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. //----------- Jeito Feio
  2.  
  3. // Routes
  4. // ...
  5. controller: "UserController",
  6. controllerAs: "$ctrl",
  7. resolve: {
  8. user: ($stateParams, UserService) => UserService.getUser($stateParams.id);
  9. }
  10. // ...
  11. // Controller
  12. function UserController(user){
  13. this.user = user;
  14. }
  15. // ...
  16.  
  17.  
  18. //------------ Jeito Lindo
  19.  
  20. // Routes
  21. // ...
  22. controller: "UserController",
  23. controllerAs: "$ctrl",
  24. resolve: {
  25. user: UserController => UserController.resolve();
  26. }
  27. // ...
  28. // Controller
  29. function UserController($stateParams, UserService){
  30. this.resolve = () => {
  31. return UserService.getUser($stateParams.id).then(user => this.user = user);
  32. }
  33. }
  34. // ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement