Last active
January 3, 2016 16:49
-
-
Save vilmosioo/8491775 to your computer and use it in GitHub Desktop.
Loading component during route resolve phase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$routeProvider | |
.when('/about-us', { | |
title: 'About Us', | |
templateUrl: 'views/about_us_view.html', | |
controller: 'AboutUs_controller', | |
resolve: { | |
resolvedData: function($q, $timeout){ | |
// create a promise that only gets resolved when all components are loaded | |
var defer = $q.defer(); | |
// Load and execute scripts. You can use any script loader you prefer. In this example I use $LAB | |
$LAB.script('scripts/controllers/aboutus_controller.js').wait(function(){ | |
// at this point, aboutus_controller.js was loaded and executed, resolve the promise | |
$timeout(defer.resolve); | |
}); | |
// return promise | |
return defer.promise; | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment