vendredi 30 janvier 2015

Ember.js: Transition somewhere else if a model exists

I want to implement logic that goes something like this:


If an value exists in storage, redirect here, else redirect there.


I'm doing it something like this:



App.IndexRoute = Ember.Route.extend({
beforeModel: function () {
var context = this;
this.store.find("thing").then(function (things) {
var thing = things.get("firstObject");
if(thing) {
context.transitionTo("some.where");
} else {
context.transitionTo("somewhere.else");
}
});
}
});


I have a feeling I am not doing it right. What is the best way to do this?


Thanks





Aucun commentaire:

Enregistrer un commentaire