Link to home
Start Free TrialLog in
Avatar of Seven price
Seven priceFlag for United States of America

asked on

initialise the object angular2

  export class DashComponents
    implements OnInit {

dashtest: IDashPosttest[];


ngOnInit(): void
this works 
this.FirstName = "testing it all";
  <input type="text" class="form-control"  [value]="FirstName"  (input)="FirstName = $event.target.value"/>

Open in new window


but this does not work
this.dashtest[0]FirstName = "testing it all"
 <input type="text" class="form-control"  #firstnameRef="ngModel" [(ngModel)]="dash.FirstName"   name="firstName"  required />;

export interface IDashPosttest {
    FirstName: string;
    LastName: string;
}

Open in new window

Error receiving Error: Error in :0:0 caused by: Cannot read property '0' of undefined
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Seven price

ASKER

EXCEPTION: Uncaught (in promise): Error: Error in :0:0 caused by: Cannot set property 'FirstName' of undefined
TypeError: Cannot set property 'FirstName' of undefined
Got it. Thanks again. have a great holiday.
You are welcome - and to you and your family as well.