使用硬编码登录。我有3种类型的用户。
if(this.loginForm.value.email == 'admin' && this.loginForm.value.password == 'admin'){
console.log(`found corresponding user.`);
this.router.navigate(['/dashboard/home']);
}
if(this.loginForm.value.email == 'USapparel&textile' && this.loginForm.value.password == 'admin'){
console.log(`found corresponding user.`);
this.router.navigate(['/dashboard/home', {company_id: '39'}]);
}
if(this.loginForm.value.email == 'USapparel&textile0118/003' && this.loginForm.value.password == 'admin'){
console.log(`found corresponding user.`);
this.router.navigate(['/dashboard/home', {company_id: '39', policy_id: 'IGT/D/PHI3/0000000001/0118/003'}]);
}
IM传递数据中,我不会在第二个Company_ID和第三Company_ID和Policy_id中传递任何事情。
在家庭组件中
if(this.company_id){
this.getSamad(this.company_id);
this.company = false;
}
if(this.policy_id){
this.getSamad2(this.policy_id);
this.company = false;
}
我有2个功能getAmad和getsamad2。但是,当我仅company_id时,它也会使用getaMad2函数。表示IM仅通过Company_ID,因此它将使用GetAmad函数?但是它使用getaMad2函数。有人可以帮助这样做多么生病吗?
我认为当您不发送值时,您应该检查" this.policy_id"的值。在这种情况下,它不会是空的,而是空的或其他的。
尝试:
if(this.policy_id) {
// policy_id available
}
else {
// policy_id not available
}
,如果您想将其发送为参数,则首先导航方法
this.router.navigate(['/dashboard/home', {company_id: '39', policy_id : null }]);
请勿在您的Angular App (至少哈希(中进行硬码explicite密码(它们(
尝试
if(this.company_id){
this.getSamad(this.company_id);
this.company = false;
} else if(this.policy_id){
this.getSamad2(this.policy_id);
this.company = false;
}