0
ember.js
및 ember-auth
gem을 사용하는 다음 컨트롤러가 있습니다. 이 컨트롤러는 작동하지만 난에 서명을받을 때마다 loginError
속성을 설정콜백 내 컨트롤러 속성 설정
BaseApp.SignInController = Auth.SignInController.extend({
email: null,
password: null,
loginError: false,
signIn: function() {
this.registerRedirect();
Auth.signIn({
email: this.get('email'),
password: this.get('password')
});
this.set('loginError', true); // Sets correctly but each time
Auth.on('signInError', function() {
console.log("This is a signin error");
});
}
});
물론이 같은 Auth.on
에 의해 호출되는 함수 내에서 true
에 loginError
를 설정하고 싶으면 무엇을 :.
BaseApp.SignInController = Auth.SignInController.extend({
email: null,
password: null,
loginError: false,
signIn: function() {
this.registerRedirect();
Auth.signIn({
email: this.get('email'),
password: this.get('password')
});
Auth.on('signInError', function() {
this.set('loginError', true); // Doesn't set the controller's property
console.log("This is a signin error");
});
}
});
그러나 콜백 내부의 범위가 다르기 때문에 이것은 분명히 작동하지 않습니다. 어쩌면 나는 아주 기본적인 것을 놓치고있을거야. 어떻게 작동시킬 수 있습니까?
[.bind (이)] (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind), (IE에 대한 IE9 필요) – harianus