Angularfire Route Resolution
I'd like to have my angularFire collection resolve on route loading. Something like: App.config ($routeProvider, angularFireProvider) -> $routeProvider.when '/test', templ
Solution 1:
I'm not exactly sure why you want the collection to resolve on route loading, as opposed to in the controller - could you elaborate? For example, the following would work too:
App.config ($routeProvider, angularFireProvider) ->
$routeProvider.when'/test',
controller: 'TestCtrl'functionTestCtrl($scope, angularFire) {
angularFire("https://<example>.firebaseio.com", $scope, "collection").
then(function() {
// The collection has been resolved and available in $scope.collection
});
}
Is it mainly a matter syntactic convenience or am I missing functionality you want in the above?
Update: For the value to be resolved before the $routeChangeSuccess
event is fired:
App.config(['$routeProvider', 'angularFire', function($routeProvider, angularFire) {
$routeProvider.when("/test", {
templateUrl: 'views/test.html'controller: 'TestCtrl',
resolve: {collection: angularFire("https://<example>.firebaseio.com")}
});
}]);
functionTestCtrl(collection) {
// collection has already been resolved to its value.
}
Post a Comment for "Angularfire Route Resolution"