У меня есть 2 компонента.
Первый: component.ts ts.
@Component({
selector: "ns-app",
templateUrl: "app.component.html",
})
export class AppComponent implements OnInit {
myid: any;
myappurl: any;
constructor(private router: Router, private auth: LoginService) {
}
ngOnInit() {
if (this.auth.isAuthenticated()) {
return true;
}
handleOpenURL((appURL: AppURL) => {
console.log('Got the following appURL', appURL);
this.myappurl = appURL
console.log(this.myappurl)
let url_1 = this.myappurl.toString();
let url_id = url_1.split("/").reverse()[0];
this.myid = url_id
let LS = require("nativescript-localstorage");
LS.setItem(this.myid)
this.router.navigateByUrl('/test/resetPasswordRequest', this.myid); //show correct this.myid
});
console.log('this.myid', this.myid) // show null
}
}
.html
<page-router-outlet></page-router-outlet>
Второй: другой компонент.Я хочу получить this.myid
и использовать в другом компоненте.
export class ResetPassIdComponent implements OnInit {
constructor() {}
ngOnInit(){
this.resetPasswordForm = this.fb.group({
'password': new FormControl('', Validators.required),
'myid': new FormControl('', Validators.required)
});
}
onReset() {
console.log(this.resetPasswordForm.value)
}
}
routing.ts
{ path: 'resetPasswordRequest', component: ResetPassIdComponent }
Любая идея, pelase, как получить this.myid в ResetPassIdComponent?
Спасибо