방금 최신 카나리아 버전의 ember로 업그레이드했고 currentUser 컨트롤러를 모든 컨트롤러에 삽입 한 초기화 프로그램이 더 이상 작동하지 않는 것을 확인했습니다.
다음은 코드입니다.
Ember.Application.initializer({
name: "fetchUsers",
after: "store",
initialize: function(container, application) {
var store, controller;
application.deferReadiness();
store = container.lookup('store:main');
controller = container.lookup('controller:currentUser');
return store.find('user').then( function(users) {
var currentUser;
currentUser = users.findBy('isCurrent', true);
controller.set('content', currentUser);
application.inject('controller', 'currentUser', 'controller:currentUser');
application.advanceReadiness();
});
}
});
이것은 릴리스 및 베타 분기에서 잘 작동하지만 카나리아에서는 다음 오류가 발생합니다.
Error: Cannot inject a `controller:current-user` on other controller(s). Register the `controller:current-user` as a different type and perform the typeInjection.
이 문제를 어떻게 해결해야합니까? currentUser를 ObjectController로 만들고 싶습니다. 가능합니까?
좋아요, 이것은 제 현재 이니셜 라이저입니다. 실제로 currentUser ObjectController를 ObjectProxy로 변경했습니다. 내 유일한 전화 끊기는 CurrentUserObjectProxy 파일을 저장할 위치입니다. 나는 모델 dir쪽으로 기울고있다.
Ember.Application.initializer({
name: "fetchUsers",
after: "store",
initialize: function(container, application) {
var store, user, proxy;
application.deferReadiness();
store = container.lookup('store:main');
proxy = App.CurrentUserObjectProxy.extend();
container.register('user:current', proxy, {singleton: true});
proxy = container.lookup('user:current');
store.find('user').then( function(users) {
user = users.findBy('isCurrent', true);
proxy.set('content', user);
application.inject('controller', 'currentUser', 'user:current');
application.advanceReadiness();
});
}
});
누군가에게 도움이되기를 바랍니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다