I have a fixture:
App.QuerySequence.FIXTURES = [
{
id: '1',
sequence: 'ATTAGAC'
}
];
which I am giving through index route:
App.IndexRoute = Ember.Route.extend({
model: function () {
return this.store.find('querySequence', '1');
}
});
and this one works. But I first need to process data of sequence. So I tried using:
App.IndexRoute = Ember.Route.extend({
model: function () {
return {
query: this.store.find('querySequence', '1'),
words: this.store.find('querySequence', '1').then(function(query) {
return getWords(query.get('sequence'), 4);
})
};
}
});
...
function getWords(sequence, wordSize) {
console.log(sequence);
var words = [];
for (var i = 0; i < sequence.length - wordSize; i++) {
words.pushObject(sequence.substr(i, wordSize));
}
return words;
}
With :
<script type="text/x-handlebars" id="index">
<!--test view-->
<label>Query: </label><span>{{query.sequence}}</span><br/>
<label>Query words:</label><br/>
<ul>
{{#each word in words}}
<li>{{word}}</li>
{{else}}
<li>Loading...</li>
{{/each}}
</ul>
</script>
Which ends up with error : Error: Assertion Failed: The value that #each loops over must be an Array. You passed {_id: 49, _label: undefined, _state: undefined, _result: undefined, _subscribers: }.
I know that getWords isn't called (also everything works with words: getWords('ACTGACCCATGAACATA', 4),
). Without returning words from model app doesn't generate any error.
What am I doing wrong? I've spend hours trying to google my problem, but maybe due to fact, that I'm a total beginner, I couldn't find anything.
Aucun commentaire:
Enregistrer un commentaire