You can create a directive with the same selector as the component, then you can override the input properties on the directive constructor.
I recommend using the Wrapper component method since it's tried and tested for many years, if not try this:
import { Component, Input, Directive, inject } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
@Directive({
selector: 'app-child',
standalone: true,
})
export class ChildDirective {
child = inject(Child);
constructor() {
this.child.mindate = 'directive set this!';
this.child.pattern = 'directive set this!';
this.child.icon = 'directive set this!';
}
}
@Component({
selector: 'app-child',
standalone: true,
template: `
{{mindate}} | {{pattern}} | {{icon}}
`,
})
export class Child {
@Input() mindate = 'nothing was set';
@Input() pattern = 'nothing was set';
@Input() icon = 'nothing was set';
}
@Component({
selector: 'app-root',
standalone: true,
imports: [ChildDirective, Child],
template: `
<app-child/><br/><br/>
<app-child
[mindate]="'input from parent'"
[pattern]="'input from parent'"
[icon]="'input from parent'"/><br/><br/>
<app-child/><br/><br/>
<app-child/>
`,
})
export class App {
name = 'Angular';
}
bootstrapApplication(App);