ルーターで作成したクラスを使用する場合Em.Application.create()
は、application.create の外部でルーターを指定する必要があります。ただし、アプリケーションは自動的に初期化されるため、ルーターはルートにルーティングしません/
。
autoinit: false
以前は、application.createに追加することで、初期化を遅らせることができました。App.deferReadiness()
これで、 andを使用することになっていますApp.advanceReadiness()
。ただし、これは機能していないようです。
そして、私はあなたがそれを別の方法で行うことが「想定されている」という感覚から逃れることができないようです.
以下の問題を示すために最小限のコードを追加しました。ここにもjsfiddleがあります
編集:
どうやら、ember に新しいルーターがあるようで、ちょっと見落としていました。コードを新しいルーターに変更しましたが、まだ機能しないと思います:P
window.App = App = Em.Application.create({
ApplicationController: Em.Controller.extend({}),
ApplicationView: Em.View.extend({
template: Em.Handlebars.compile('{{outlet}}'),
}),
ExtendedPatientController: Em.ObjectController.extend({}),
ExtendedPatientView: Em.View.extend({
classNames: ['patient-view', 'extended'],
template: Em.Handlebars.compile('{{name}}')
}),
Patient: Em.Object.extend({
name: undefined,
}),
});
App.Router.map(function (match) {
match('/').to('application', function (match) {
match('/').to('extendedPatient');
})
});
App.deferReadiness();
App.ExtendedPatientRoute = Em.Route.extend({
setupController: function (controller) {
controller.set('', App.Patient.create({
name: "Bert"
}));
},
renderTemplates: function () {
this.render('extendedPatient', {
into: 'application'
});
}
});
App.advanceReadiness();