hi I want to send data from parent to child in angular 6 my child.ts
this.rest.sendRequest('GET', 'station', null).subscribe(
value => {
this.data = value['Station'];
this.source.load(this.data);
console.log(this.data);
},
);
my parent.ts
addStation() {
this.rest.sendRequest( 'POST', 'station', this.station).subscribe();
}
my child.html
<nb-card>
<nb-card-header>
لیست ایستگاه ها
</nb-card-header>
<nb-card-body>
<ng2-smart-table [getValueFromParent]="value" [settings]="settings" [source]="source" (deleteConfirm)="onDeleteConfirm($event)" (editConfirm)="onEditConfirm($event)">
</ng2-smart-table>
</nb-card-body>
</nb-card>
my parent.html is :
<nb-card>
<nb-card-header>
ایستگاه
</nb-card-header>
<nb-card-body>
<div class="row">
<div class="col-md-4">
<nb-card>
<nb-card-header>
<p>افزودن ایستگاه جدید</p>
</nb-card-header>
<br>
<nb-card-body>
<h3>افزودن ایستگاه</h3>
<form (ngSubmit)="addStation()" #form="ngForm" autocomplete="on" >
<div class="form-control">
<div>
<label for="title">
عنوان
</label>
<input class="form-control" id="title" name="title" nbInput [(ngModel)]="station.title" placeholder="عنوان">
</div>
<div>
<button nbButton type="submit" >افزودن ایستگاه</button>
</div>
</div>
</div>
</form>
</nb-card-body>
</nb-card>
</div>
<div class="col-md-8">
<ngx-smart-table></ngx-smart-table>
</div>
</div>
i want when form sent my table update automaticly how can i do that?
edit: i added the whole html
my this.station is object and my this.data is array
and i have used ng2-smart-table
@Input()to pass data from parent to child. - Rupesh