在我的Ember页面中,我没有controller
,但我有路由和hbs文件。当用户点击复选框时,如何在路径操作方法中检索值(true/false
)?
这是我的模板:
<div class="agreementContent">
{{rdc-checkbox label="*I agree to the <a href='#' (action 'goToTerms')> Terms & Conditions </a>" action="acceptTerms" checked=terms}}
</div>
我的路线档案:
import Ember from 'ember';
export default Ember.Route.extend({
model(params){
console.log('got the model', params );
return this.store.peekRecord('card-list', params.id );
},
actions:{
goToTerms(){
console.log("confirm clicked");
},
acceptTerms( event ){
const value = this.get('terms');
console.log("accept Terms clicked", value );//undefined
}
}
});
更新
试过像:
actions:{
goToTerms(){
console.log("confirm clicked");
},
acceptTerms( event ){
console.log("accept Terms clicked", this.modelFor(this.routeName) );// gives the model value as null
}
}