0
두 자식 사이를 전환하는 뷰를 렌더링하려고합니다. (또는 그래서 희망합니다.) 뭔가 올바르게 작동하지 않습니다. app.js에ember.js를 사용하여 하위 뷰 사이를 전환 하시겠습니까?
{{#view App.LoginFormView isVisibleBinding="user.isNotAuthenticated" }}
Username: {{view Ember.TextField valueBinding="user.loginName"}}/
Password: {{view Ember.TextField valueBinding="user.userPassword" type="password"}}
<button class="btn" {{ action "login" }} {{bindAttr disabled="user.isNotValid"}}>Login</button>
{{/view}}
{{#view App.LoginInfoView isVisibleBinding="user.isAuthenticated" }}
You are logged in as {{user.loginName}}. Click <a {{action "logout"}}>here</a> to logout
{{/view}}
나는 다음과 같은 한 : 여기 내 템플릿입니다
App.User = Ember.Object.extend({
loginName:'',
userPassword:'',
rememberMe:true,
isNotValid:function(){
return (this.get("loginName") == '') || (this.get("userPassword") == '');
}.property('loginName', 'userPassword'),
isAuthenticated:false,
isNotAuthenticated:function(){
return !this.isAuthenticated;
}.property('isAuthenticated')
});
App.AuthenticationController = Ember.Controller.extend({
login:function() {
alert("loginName:"+this.user.get('loginName')+";\n"+
"userPassword:"+this.user.get('userPassword')+";\n"+
"rememberMe:"+this.user.get('rememberMe')+";\n");
this.user.isAuthenticated = true;
},
user:App.User.create()
});
App.AuthenticationView = Ember.View.extend({
templateName: 'authentication',
userBinding:"App.AuthenticationController.user"
});
App.LoginFormController = Ember.Controller.extend({
userBinding:"App.AuthenticationController.user"
});
App.LoginFormView = Ember.View.extend();
App.LoginInfoController = Ember.Controller.extend({
userBinding:"App.AuthenticationController.user"
});
App.LoginInfoView = Ember.View.extend();
App.Router = Ember.Router.extend({
enableLogging:true,
root: Ember.Route.extend({
index: Ember.Route.extend({
route: '/',
connectOutlets: function(router){
router.get('applicationController').connectOutlet('authentication','authentication');
},
login:function(router){
router.get('authenticationController').login();
}
})
})
});
오전 데 문제가보기 IsAuthenticated는 속성의 변화에 전환하지 않습니다. 나는 자동적으로 일어날 인상을 받고 있었지만 아직 그렇지 않다. 이 방법을 만드는 방법에 대한 아이디어가 있습니까? 또는 나는 근본적인 뭔가를 놓치고있다. (ember.js 초보자는 여기에 온순하게 따라야한다 :-))
건배, Alex.
당신은 다음과 같은 방법으로 사용자 인증을 구현할 수 있습니다
[Router Primer] (http://emberjs.com/guides/router_primer/)에서 살펴볼 수 있습니다. – zentralmaschine
나는 그것을했고 도움이되지 않는다. – ash
현재 상태는 무엇입니까? 둘 다보기가 동시에 표시 되나요? 또한 이러한 뷰 템플릿이 다른 뷰 템플릿 (부모 뷰와 같은)에 렌더링되고 있습니까? 그렇다면 객체를 가져올 때 isVisibleBinding = "parentView.user.isNotAuthenticated"와 같은 바인딩을 변경하고 싶습니다. 에 대한 바인딩이 상위 뷰에서 이루어집니다. 이'parentView'는 1.0pre 또는 pre2 이후 사용되어야한다고 생각합니다. – MilkyWayJoe