Skip to content

Instantly share code, notes, and snippets.

<!-- person1 is an object of type Person -->
<array-coercion
[strings]="'array item 1'"
[persons]="person1"
></array-coercion>
<!-- person1 & person2 are objects of type Person -->
<array-coercion
[strings]="['array item 1', 'array item 2']"
[persons]="[person1, person2]"
></array-coercion>
@umairhm
umairhm / array-coercion.component.ts
Last active July 6, 2020 00:35
Example of component that takes arrays as inputs, and renders those arrays using *ngFor
import { Component, Input } from '@angular/core';
import { Person } from './person.interface';
@Component({
selector: 'array-coercion',
template: `...`
})
export class ArrayCoercionComponent {
@Input() strings: Array<string>;
@Input() persons: Array<Person>;