我正在尝试从路由器验证我的模型。但是alwasy返回true
。但我不确定我做的是完全正确的。请帮助我从路由器验证我的模型。
这是我的代码:
import Ember from 'ember';
import Validations from '../components/validation';
export default Ember.Route.extend(Validations, {
model(){
return {"emailAddress" : null }
},
actions:{
formValidate(){
var emailAddress = this.controllerFor(this.routeName).get('model.emailAddress');
console.log("email", emailAddress );
//seems not works the validate method
this.validate().then(({model,validations})=>{
if(validations.get('isValid')){
console.log('this is valid', validations.get('isValid') );
}
});
}
}
});
用于直播演示:ember-twiddle