Let\'s say I got a component with a fixed input parameter type,
@Component({
selector: \'fixed\',
template: \'{{value}}\'
})
e
It seems you can use generic type parameters in Angular 2 child components.
@Component({
selector: 'app-child',
template: 'Generic Child
{{cp}}
'
})
export class GenericChildComponent {
@Input() cp: T;
}
import { GenericChildComponent } from './generic-child.component';
@Component({
selector: 'app-root',
template: '
',
directives: [GenericChildComponent]
})
export class ParentComponent {
p1: string = 'property 1';
p2: number = 100;
}
This works without recourse either to the ViewChild technique suggested above or to a base class technique suggested here.