I saw a few code examples here Undo AngularJS route change before loading the model to prevent flickering
And right now, although this was the right way, I need my LOAD controller to be only when the solution has finished loading, usually most of the examples around will tell you that the code was allowed in the router as a built-in function, but it sounds wrong. The controller needs this, so it is not necessary for the controller to implement this function. It sounded exactly what I was looking for, i.e. Does this seem to use a prototype template?
function PhoneListCtrl($scope, phones) { $scope.phones = phones; $scope.orderProp = 'age'; } PhoneListCtrl.resolve = { phones: function(Phone, $q) {
The problem is that I have such a controller
'use strict'; angular.module('TestApp') .controller('ItemsCtrl', function ($scope) { });
So, how do I apply a new function on the controller when my controller is declared inside the module?
I really need something like
TestCtrl.resolve = { items: function( $q) { .......... return deferred.promise; } }
This would then allow me to have in my router.
when('/items', { templateUrl: 'views/items.html', controller: 'TestCtrl', resolve: 'TestCtrl.resolve'}). // Need to use ' around resolve?
But I'm confused, how could I make this work?
I would really like any feedback, I'm at a loss.