Angular 6 How to pass array in one component to other [closed]
I want to get data from textboxes and show them in table. But the textboxes are in other component and table is in the other component means table is children, so how can we pass data from textboxes to table?

closed as off-topic by gustavohenke, David Walschots, Vega, Nkosi, Shree Jan 1 at 10:07
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – gustavohenke, David Walschots, Shree
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
I want to get data from textboxes and show them in table. But the textboxes are in other component and table is in the other component means table is children, so how can we pass data from textboxes to table?

closed as off-topic by gustavohenke, David Walschots, Vega, Nkosi, Shree Jan 1 at 10:07
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – gustavohenke, David Walschots, Shree
If this question can be reworded to fit the rules in the help center, please edit the question.
2
Just read the documentation.
– David Walschots
Jan 1 at 9:52
add a comment |
I want to get data from textboxes and show them in table. But the textboxes are in other component and table is in the other component means table is children, so how can we pass data from textboxes to table?

I want to get data from textboxes and show them in table. But the textboxes are in other component and table is in the other component means table is children, so how can we pass data from textboxes to table?


edited Jan 1 at 9:53
David Walschots
8,25452648
8,25452648
asked Jan 1 at 7:01


ZaIn KhAnZaIn KhAn
154
154
closed as off-topic by gustavohenke, David Walschots, Vega, Nkosi, Shree Jan 1 at 10:07
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – gustavohenke, David Walschots, Shree
If this question can be reworded to fit the rules in the help center, please edit the question.
closed as off-topic by gustavohenke, David Walschots, Vega, Nkosi, Shree Jan 1 at 10:07
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – gustavohenke, David Walschots, Shree
If this question can be reworded to fit the rules in the help center, please edit the question.
2
Just read the documentation.
– David Walschots
Jan 1 at 9:52
add a comment |
2
Just read the documentation.
– David Walschots
Jan 1 at 9:52
2
2
Just read the documentation.
– David Walschots
Jan 1 at 9:52
Just read the documentation.
– David Walschots
Jan 1 at 9:52
add a comment |
1 Answer
1
active
oldest
votes
Since this a parent-child relationship between two components, you can create an @Input
property in your Child Component and pass it from the Parent Component template:
Something like this:
Template of Parent Component:
<app-table
*ngIf="data.length"
[data]="data">
</app-table>
Child Component:
import { Component, Input } from '@angular/core';
@Component({...})
export class TableComponent {
@Input() data: any;
}
Here's a Working Sample StackBlitz for your ref.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Since this a parent-child relationship between two components, you can create an @Input
property in your Child Component and pass it from the Parent Component template:
Something like this:
Template of Parent Component:
<app-table
*ngIf="data.length"
[data]="data">
</app-table>
Child Component:
import { Component, Input } from '@angular/core';
@Component({...})
export class TableComponent {
@Input() data: any;
}
Here's a Working Sample StackBlitz for your ref.
add a comment |
Since this a parent-child relationship between two components, you can create an @Input
property in your Child Component and pass it from the Parent Component template:
Something like this:
Template of Parent Component:
<app-table
*ngIf="data.length"
[data]="data">
</app-table>
Child Component:
import { Component, Input } from '@angular/core';
@Component({...})
export class TableComponent {
@Input() data: any;
}
Here's a Working Sample StackBlitz for your ref.
add a comment |
Since this a parent-child relationship between two components, you can create an @Input
property in your Child Component and pass it from the Parent Component template:
Something like this:
Template of Parent Component:
<app-table
*ngIf="data.length"
[data]="data">
</app-table>
Child Component:
import { Component, Input } from '@angular/core';
@Component({...})
export class TableComponent {
@Input() data: any;
}
Here's a Working Sample StackBlitz for your ref.
Since this a parent-child relationship between two components, you can create an @Input
property in your Child Component and pass it from the Parent Component template:
Something like this:
Template of Parent Component:
<app-table
*ngIf="data.length"
[data]="data">
</app-table>
Child Component:
import { Component, Input } from '@angular/core';
@Component({...})
export class TableComponent {
@Input() data: any;
}
Here's a Working Sample StackBlitz for your ref.
answered Jan 1 at 7:51
SiddAjmeraSiddAjmera
15.6k31239
15.6k31239
add a comment |
add a comment |
2
Just read the documentation.
– David Walschots
Jan 1 at 9:52