ember.js - how to watch specified `properties` in `router` and react accordinlgy? -
in app, user setting 6 seperate digits. can delete/re-enter/enter values in input. controller sending values router.
when router watches properties, take user next page. question how watch properties ( specified properties ) , react accordingly?
here router code ( snippet ):
export default ember.route.extend({ otp1:null, otp2:null, otp3:null, otp4:null, otp5:null, otp6:null, mywatcher(){ console.log('all properties available, enable next'); }, setupcontroller(controller,model) { this._super(...arguments); this.controllerfor('auth-page.credit-card.credit-cardno').set('enablenext', false); }, actions:{ setupcardnumber( number, index ){ this.set('opt'+index, number ); //setting values console.log( 'setting', this.get('opt'+index) );//gets property } } }
as far understand code, create if-statement
:
setupcardnumber( number, index ){ if (this.get('otp1') && this.get('otp2') && this.get('otp3') && this.get('otp4') && this.get('otp5') && this.get('otp6') ) { this.transitionto('next-page'); } }
i advice create map or something, code tends unmaintainable rather quickly.
wiki
Comments
Post a Comment