The only possibility I can see is that Whatever.query() is resolving to an empty array. There's nothing else that would introduce an empty array.
Try changing Whatever.query() to Whatever.query().then (result) -> $log.debug result result On Tue, Oct 7, 2014 at 3:23 AM, Anton Trapp <[email protected]> wrote: > Hi! > > Following code: > > $stateProvider.state('somestate', { > url: '/someurl' > views: { 'main': { templateUrl: 'views/whatever/whatever.html' } } > resolve: { > whatevers: ['$log', 'Whatever', ($log, Whatever) -> > $log.debug "State whatever : resolve - whatevers" > Whatever.query() > ] > } > onEnter: ['$log', '$state', '$stateParams', '$timeout', 'whatevers', > ($log, $state, $stateParams, $timeout, whatever) -> > $log.debug ' Check if we have any whatevers for this user', _. > isEmpty(whatevers), whatevers > > > If I navigate to this state the output is: > > State whatever : resolve - whatevers -> resolving, great that far... > Check if we have any whatevers for this user true [] -> not so good that > far > > If I type in the URL and load the page (don't come from another state) I > get "false [all my data]"... > > So I can't use resolve except for page reloading... If I throw away the > not working resolve stuff and read the data in the onEnter ($promise.then > ...) it is working every time, could live without resolve but I don't have > a scope in onEnter, so I have to read the data twice to get it in the > controller... :( > > Any ideas? > > Thank you very much in advance! > > Kind regards, > Anton > > -- > You received this message because you are subscribed to the Google Groups > "AngularJS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. > -- chrisrhoden -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
