Angular passing array from parent to child component

Viewed 29213

Before we start, I started learning Angular about 1 week ago, don't be afraid to take it right back to basics.

So how do you do it? In app.component.ts I have an standard array that needs to be accessable by multiple child components.

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  masterArray = ['Create', 'Foo', 'Bar'];
}

How do pull this into child components generated by angular cli. For example I need to use it in the navigation component to generate the navigation panel.

<li *ngFor = "let i of masterArray; let ind = index">
  <a>{{i}}</a>
</li>
2 Answers
Related