I have 2 components.
First: component.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>
Second: another component. I wish to retrieve this.myid
and utilize it in a different component.
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 }
Any suggestions on how to obtain this.myid
in ResetPassIdComponent?
Thank you