I done Angular 2 application For that i am doing unit testing, but params 
cant read in that unit tesing

// This is my code

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

@Component({
  moduleId: module.id,
  selector: 'moivetwo-app',
  template:`<div class="container">
   
    <div class="row" style="text-align:center;">
        <div class="col-sm-12">
            <h3><span class="label label-info">{{lblName}}</span></h3>
        </div>
    </div>
        <div class="row" >  
         <div class="col-sm-12">  
                <input class="form-control input-lg" id="inputlg" 
type="text" [(ngModel)]='txtValue' [style.border-color]='errColor'>
         </div>            
        </div>
    <br/>
    <div class="row" style="text-align:center;">
        <span class="input-group-btn">
            <button class="btn btn-success btn-lg" type="button" id="bot1" 
(click)='onClick()'>{{ btnTitle }} </button>
        </span>
        </div>
    <br/>
    <div class="row" style="text-align:center;">
        <span class="input-group-btn" *ngIf='navigated'>
            <button class="btn btn-success btn-lg" type="button" 
(click)='goBack()'>Back </button>
        </span>
    </div>
    </div>`
  
})

export class EntryPage
{
    movieName:string;    
    btnTitle:string = "Continue";
    txtValue:string;
    navigated = false;
    errColor:string;    
    lblName:string;

    constructor(   
    private activatedRoute: ActivatedRoute,
    private router: Router) {}

    goBack(): void {    
        this.router.navigate(['one']);
    }

    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;            
        }
        
    }

    onClick(){
        if(this.txtValue!=undefined && this.txtValue!="")
        {
            this.errColor="";
            if(this.movieName != undefined) 
            {                                                        
                    let link11 = ['/compare', this.movieName,this.txtValue];
                    this.router.navigate(link11);                    
            }
            else
            {                 
                    let link = ['/two', this.txtValue];
                    this.router.navigate(link);  
            }        
              
        } else  this.errColor="red";
    }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Angular" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to