Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. var app = angular.module("app", ["ngRoute"]);
  2.  
  3. app.config(function ($routeProvider) {
  4. $routeProvider
  5. .when('/', {
  6. templateUrl: "app.html",
  7. controller: "ViewCtrl",
  8. resolve: {
  9. first: function () {
  10. return "Hello world";
  11. },
  12. second: function ($q, $timeout) {
  13. var defer = $q.defer();
  14. $timeout(function () {
  15. defer.reject("Your network is down");
  16. }, 500);
  17. return defer.promise;
  18. }
  19. }
  20. })
  21. });
  22.  
  23. app.run(function ($rootScope) {
  24. $rootScope.$on("$routeChangeError", function (event, current, previous, rejection) {
  25. console.log(event);
  26. })
  27. });
  28.  
  29. app.controller("ViewCtrl", function ($scope, first, second) {
  30. console.log(first, second);
  31. $scope.model = {
  32. message: "I'm a great app!"
  33. }
  34. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement