angular - How to render angular4 universal with query parameter route -
i'm trying migrate angular 1.4 angular4 universal seo purposes. works well. have 1 route.
confirm email after registration http://localhost/confirmemail/09393?code='xxxxxxxxx'
ngoninit() { let param_id = this.route.snapshot.params['id']; let param_code = this.route.snapshot.queryparams['code']; this.message = ''; this.authservice.getconfirmation(param_id, param_code) .subscribe( data => { this.router.navigate(['/login']); }, error => { } ); }
- looks gets rendered on server , calls rest api getconfirmation.
- once ui rendered on client calls getconfirmation again.
is there way. don't wanna call rest api server side, call client code.
this worked me.
check see if global window object present. call rest api confirmed
ngoninit() {
if (typeof window !== 'undefined') { let param_id = this.route.snapshot.params['id']; let param_code = this.route.snapshot.queryparams['code']; this.message = ''; this.getconfirmation(param_id, param_code); }
}
Comments
Post a Comment