Search code examples
htmlarraysangularsearchcomponents

how to access arrays from different component in angular


I'm new to programming and just wondering how I can access arrays from a different component in angular project

This data chips: Array<String> = ["One", "Two", "Three"]; are inside tags.component.ts file

I want to access those data inside home.component.ts file

I have search filter inside home component so I'm trying to access those data and to display inside home component when a user search for those data.

Thanks


Solution

  • There is more than one way to do that. Take a look at this material, you'll learn from this https://fireship.io/lessons/sharing-data-between-angular-components-four-methods/

    Long story short - there is a couple of ways to share data (via Input, via ViewChild, via Output() and EventEmitter) and sharing data between unrelated components with a Service.

    I hope that will help!