I'm new to Ember.js and Ember-cli and have this rather basic problem of not being able to fetch a specific model value in my ArrayController and manipulate it here. I read several times through the ember.js doc about Controller Setup and Display of Models
http://emberjs.com/guides/controllers/representing-multiple-models-with-arraycontroller/
but didn't find a solution to my case yet.
Here are my route, controller and model files:
// /routes/sequences.js
import Ember from 'ember';
var SequencesRoute = Ember.Route.extend({
model: function() {
return this.store.find('sequences');
},
setupController: function(controller, model) {
this._super(controller, model);
}
});
export default SequencesRoute;
// /controllers/sequences.js
import Ember from 'ember';
var SequencesController = Ember.ArrayController.extend({
init: function() {
this._super();
this.typeSeq();
},
i: 0,
seqData: function(){
var seq = this.get('model.nts');
return seq;
}.property('model.nts'),
len: function(){
var slen = this.get('seqData');
return slen.length;
}.property('seqData'),
typeSeq: function() {
var tthis = this;
var sequence = this.get('seqData');
var lenn = this.get('len');
if (tthis.i <= lenn){
console.log(tthis.i);
console.log(sequence.substring(tthis.i,tthis.i+1));
tthis.i++;
Ember.run.later(function(){
tthis.typeSeq();
}, 200
);
}
else{
return false;
}
}
});
export default SequencesController;
// /models/sequences.js
import DS from 'ember-data';
var Genes = DS.Model.extend({
geneName: DS.attr('string'),
nts: DS.attr('string')
});
Genes.reopenClass({
FIXTURES: [
{
id: 1,
geneName: "Monoamine Oxidase A",
nts: "CTGCAGCGAGCGCGGGAAGCGGGACAGGGCCTAGAGTCACTTCTCCCCGCCCCTGACTGGCCCG"
},
{
id: 2,
geneName: "Monoamine Oxidase B",
nts: "TTTCTGCAGCGAGCGCGGGAAGCGGGACAGGGCCTAGAGTCACTTCTCCCCGC"
}
]
});
export default Genes;
Especially setting the property for seqData in my controller is not clear to me. What has exactly to be called to get my model data into the property? Will the setupController method in my router set a model property in my ArrayController embermagically, so I can fetch it via model.nts ? Right now, my ember app will build, but the var sequence, which is set in the typeSeq function, remains undefined.
Would be great to hear some answers from you or grab a link for a nice tutorial regarding this topic!