Ember“转型中止”

时间:2014-02-02 07:28:25

标签: javascript ember.js ember-data

我的Ember App Kit项目中有一条从REST服务获取的路由。这是代码:

var PatientsIndexRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, {
  model: function() {
    return this.store.find('patient').then(function(res) {
      console.log("success");
      return res;
    }, function() {
      console.log("error", arguments);
    });
  }
});

export default PatientsIndexRoute;

然而,当我导航到路线(在这种情况下为/patients/index)时,页面似乎什么都不做。这是控制台:

23:09:46.946 OPTIONS http://localhost:7000/patients/ [HTTP/1.0 200 OK 1ms]
23:09:46.881 "Attempting transition to patients.index" ember.js:3450
23:09:46.883 "Transition #3: patients.index: calling beforeModel hook" ember.js:3450
23:09:46.883 "Transition #3: patients.index: calling deserialize hook" ember.js:3450
23:09:46.948 GET http://localhost:7000/patients/ [HTTP/1.0 200 OK 4ms]
23:09:46.911 "success" app.js:171
23:09:46.912 "Transition #3: patients.index: calling afterModel hook" ember.js:3450
23:09:46.912 "Transition #3: Resolved all models on destination route; finalizing transition." ember.js:3450
23:09:46.915 "generated -> controller:patients.index" [object Object] ember.js:3450
23:09:46.918 "Transition #3: patients.index: transition was aborted" ember.js:3450

注意transition was aborted:这是转换中止时显示的通用消息,但我无法确定 从中止转换。我不认为它在获取模型时被中止,但是在afterModelsetupController之后的某个时间。

有趣的是,如果我删除model功能,它将导航到路线。同样奇怪:它渲染包装模板templates/patients.hbs,但不渲染templates/patients/index.hbs模板。

编辑1: 这是路由器:

var Router = Ember.Router.extend(); /

Router.map(function() {
  // Auth-example
  this.route('index', { path: '/' });
  this.route('protected');
  this.route('login');
  this.resource('patients', function() {
    this.route('new');
  });
});

export default Router;

1 个答案:

答案 0 :(得分:1)

我的问题是我错过了“patients.hbs”模板 - 我有一个“patients / new.hbs”和“patients / index.hbs”。本来很好的抱怨或更具体一点。