lundi 25 mai 2015

Not able to share dependencies on a controller

I have an application running with Ember 1.12.0. I have a simple template called /app/templates/repositories.hbs with this content :

{{controllers.user.login}}

I added this in the controller app/controllers/repositories.js :

import Ember from 'ember';

export default Ember.ArrayController.extend({
  needs: "user",
});

I have this route :

import Ember from 'ember';

export default Ember.Route.extend({
  model: function(params) {
    var user = this.modelFor('user');
    console.log(user);
    return Ember.$.getJSON('http://ift.tt/1gcW4Wp'+user.login+'/repos');
  }
});

And this router :

import Ember from 'ember';
import config from './config/environment';

var Router = Ember.Router.extend({
  location: config.locationType
});

Router.map(function() {
  this.route('index', {path: '/'} );
  this.resource('user', {path: '/users/:login'}, function() {
    this.resource('repositories');
  });
});

export default Router;

According to the documentation. I should show the user login but I have just nothing. It show the user object in the console but not in the view.

Is the a solution ?




Aucun commentaire:

Enregistrer un commentaire