Poornima Poornima - 8 months ago
360 0

I write code for getting input value and with that i need to route next page,

But it showing " Cannot read property 'params' of undefined", in this version "Params" only accepted in @angular/router,

If i call ngOninit, then it showing error, please help me to solve the issue.


Angular Unit testing

import { ActivatedRoute, Params,Router } from '@angular/router';

  ngOnInit(): void {
        this.movieName = this.activatedRoute.snapshot.params['movie1name'];
            if (this.movieName !== undefined) {
                this.lblName = "Second Movie";
            //this.movieName = params['movie1name'];
            this.navigated = true;
            } else {
                this.lblName = "First Movie";
            this.navigated = false;