컨트롤러가 ('모델러'경로로) 전환 될 때마다 컨트롤러 동작을 트리거해야하지만 제대로 작동하지 않을 수 있습니다.Ember js - 경로가 활성화 될 때 컨트롤러 동작을 트리거하는 방법
var Router = Ember.Router.extend({
location: config.locationType,
actions: {
loading: function() {
this.controllerFor('modeller').send('loading');
},
didTransition: function() {
this.controllerFor('modeller').send('didTransition');
}
}
});
Router.map(function() {
this.route('modeller', { path: 'modeller'});
this.route('welcome', { path: '/'});
});
export default Router;
그리고 내 모델러 컨트롤러 : 내 router.js 파일입니다
export default Ember.Controller.extend({
needs: 'modeller',
loading: function() {
console.log("loading")
},
didTransition: function() {
console.log("didTransition")
},
});
하지만 콘솔에 로그인 할 때 그 작업 중 하나를 얻을 수 없습니다. 모든 포인터 크게 감사.
UPDATE :
아마 내가 엠버 2.1.0를 사용하고 언급해야한다!
그래서 내가 사용한 솔루션은 setupController 였지만 app/routes/modeller.js 아래의 특정 모델러 경로 파일에도이 코드를 넣어야했습니다. 이전에는 app/router.js에서 모든 작업을 수행하려고했지만 거기에서 작동하지 않았습니다. 그래서 최종 솔루션은 다음과 같습니다
# app/routes/modeller.js
import Ember from 'ember';
export default Ember.Route.extend({
setupController: function(controller, model) {
this.controllerFor('modeller').activate();
}
});
와 ..
# app/controllers/modeller.js
export default Ember.Controller.extend({
needs: 'modeller',
activate: function() {
console.log("activate")
},
});