私は ember.js で次のように実装しました。コードは特定のポイントまで機能します。
ルート URL、つまり「/」でアプリケーションを入力しても URL は変更されず、tasks.index に移動し、#/tasks を表示して URL の変更を反映する必要があります。
しかし、'#/tasks' に移動すると正しく動作し、'hello from index view' というメッセージが表示されます。
Google Chrome バージョン 19 と ember.js エッジを使用しています。
どんな助けでも大歓迎です。
App = Em.Application.create({});
App.IndexView = Em.View.extend({
template: Em.Handlebars.compile(
'hello world from index'
)
});
App.ShowView = Em.View.extend({
template: Em.Handlebars.compile(
'hello world from show'
)
});
App.Router = Ember.Router.extend({
location: 'hash',
rootElement: "#my-app",
enableLogging: true,
root: Ember.State.extend({
index: Ember.State.extend({
route: '/',
redirectsTo: 'tasks.index'
}),
tasks: Ember.State.extend({
route: '/tasks',
index: Ember.ViewState.extend({
route: '/',
view: App.IndexView
}),
show: Ember.ViewState.extend({
route: '/show',
view: App.ShowView
})
})
})
});
App.initialize();