Poornima Poornima - 9 days ago
75 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.

AngularJS

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;
            console.log(this.movieName);           
            } else {
                this.lblName = "First Movie";
            this.navigated = false;            
        }
        
    }