I have a simple application with a model, route and controller. I can't access the data from the model in my controller. I use ember-cli so I have the following structure:
/app/router.js
var Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('logs',{path: '/'});
});
export default Router;
/app/routes/logs.js
export default Ember.Route.extend({
controllerName: 'logs',
model: function() {
return this.store.find('logs');
}
});
/app/models/logs.js
export default DS.Model.extend({
ip: DS.attr('string'),
timestamp: DS.attr('number'),
visited_resource: DS.attr('string'),
pretty_string: DS.attr('string')
});
/app/controllers/logs.js
export default Ember.Controller.extend({
url: function() {
var model = this.get('model');
var basePath = "http://example.com";
var path = model.visited_resource;
return basePath+path
}.property('visited_resource')
});
My problem is that the model.visited_resources
, or this.get('model.visited_resources')
or this.get('model.[any param]')
is undefined.
If I log the whole model object and inspect it, all my data is there! ! http://i.stack.imgur.com/nkvyT.png
It's just that the controller can't access it. What am I doing wrong?
ArrayController
and every thing will fall into place. – guleria