如何将值存储到构造函数的变量中?

时间:2019-08-20 13:25:42

标签: ionic4

我可以在构造函数之外获取this.operator.lable的值。我在构造函数之外需要它

operator: {} = {}; 
constructor( private route: ActivatedRoute, private router: Router ) { 
    this.route.queryParams.subscribe(params => { 
       if (this.router.getCurrentNavigation().extras.state) { 
           this.data = this.router.getCurrentNavigation().extras.state; 
           this.operator = this.data.operator; 
        }
    });
}
this.validation_messages.number.push({ type: 'required', message: this.operator.lable + ' is required.' }); 
this.validation_messages.number.push({ type: 'pattern', message: this.operator.message });

0 个答案:

没有答案