ログインできるシンプルなアプリは次のようになります。
{{#view App.mainV}}
{{#if logged}}
Hey!
{{else}}
<!-- Login form here when clicked: App.mainC.login()-->
{{/if}}
{{/view}}
サンプルコントローラーは次のとおりです。
App.mainC = Ember.ArrayController.create({
login: function(){
if(ok)//Everything went fine
App.mainV.logged = true;
}
});
ここにmainVがあります:
App.mainV = Ember.View.extend({
logged: false,
test: function()
{
console.log('JO');
}
});
このアプリに関して 2 つの質問があります。
- Logged を true ビューに変更しても変更されないのはなぜですか?
App.mainV.test() を呼び出すと、エラーが発生します。なんで?
TypeError: 'App.mainV.test' は関数ではありません