Ramnath Bodke

Ramnath Bodke

  • 1.5k
  • 268
  • 14.6k

How to assign value to class in angular 5?

Apr 23 2018 1:33 AM
I have angular class
  1. export class Parameters  
  2. {  
  3. SearchString:string;  
  4. }  
I have code in component.ts file
  1. strparameters:Parameters;  
  2. ngOnInit() {  
  3. this.strparameters.SearchString="";  
  4. this.dataservice.getEmployee(this.strparameters).subscribe((tempdate) =>{  
  5. this.employeelist=tempdate;  
  6. })  
  7. ,err=>{  
  8. console.log(err);  
  9. }  
  10. }  
it gives me error -
 
ERROR TypeError: Cannot set property 'SearchString' of undefined
how can assign input value to SearchString in component.ts file ? please help here

Answers (2)