ember.js用户参数没有传递给模型

时间:2015-02-19 15:07:00

标签: ember.js

我有一个'手表'应该显示游戏和团队信息的模板。我还想在页面上显示当前登录用户的详细信息。

但是,当我添加('user', params.id)时,我收到错误params is not defined ReferenceError:

路由/ watch.js

App.WatchRoute = Ember.Route.extend({
  model: function() {
    return Ember.RSVP.hash({
      game: this.store.find('game'),
      team: this.store.find('team'),
      user:  this.store.find('user', params.id)
    })
  }
});

模型/ user.js的

App.User = DS.Model.extend({
  uid: DS.attr('string'),
  firstName: DS.attr('string'),
  lastName: DS.attr('string'),
  email: DS.attr('string'),
  profileImage: DS.attr('string'),
  timestamp: DS.attr('number')
});

模型/ game.js

App.Game = DS.Model.extend({
  gameName: DS.attr('string'),
  teams: DS.hasMany('team'),
  timestamp: DS.attr('number')
});

模型/ team.js

App.Team = DS.Model.extend({
  teamName: DS.attr('string'),
  game: DS.belongsTO('game'),
  timestamp: DS.attr('number')
})

router.js

App.Router.map(function() {
  this.resource('login');
  this.resource('logout');
  this.resource('signup', {path: '/'});
  this.resource('home', { path: '/:id' });
  this.resource('watch', { path: '/watch/:id' });
  this.resource('games');
  this.resource('game', {path: 'teams/:id'});      
  this.resource('teams');
  this.resource('team', {path: 'teams/:id'});
});

1 个答案:

答案 0 :(得分:0)

我已经解决了这个问题。我没有将手表包含在带有this.get('user')

的application.js中