This demo perfectly demonstrates the thing you try to achieve.
첫째, 응용 프로그램의 경로에서 작업을 정의 :
import Ember from 'ember';
export default Ember.Route.extend({
actions: {
myActionFromApp() {
console.log('myAction from application fired');
}
}
});
다음 구성 요소에 대한 행동의 템플릿 통과 이름 :
{{my-component myAction='myActionFromApp'}}
는 그런 다음 구성 요소에서 ApplicationRoute 조치를 호출 할 수 있습니다 :
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
myAction() {
this.sendAction('myAction');
}
}
});
콘솔
<button {{action 'myAction'}}>Fire action myAction</button>
결과는 다음과 같습니다 : 당신이 예상된다 버튼을 클릭하면 응용 프로그램에서
시켜라가
을 발사 누군가가 버튼을 클릭 할 때 데모에서
나는 그것을 할.