I have a massive headache trying to figure this out. I am wanting to create a custom input element I can use in my Angular/Ionic application. How can I use Angular attributes with these custom elements, like FormControlName for example.
<my-custom-stencil-input type="text" formControlName="firstName"></my-custom-stencil-input>
I have the following code below, but it is showing errors when I attempt to use FormControlName.
import { Component, h, Prop } from '@stencil/core';
@Component({
tag: 'ba-text-input-one',
styleUrl: './text-input-1.component.css',
scoped: true,
})
export class TextInputOne {
@Prop({reflect: true}) type: string;
@Prop({reflect: true}) placeholder: string;
@Prop({reflect: true}) formControlName: string;
render() {
return (
<div id="cmp">
<div id="icon-area">
<slot name="icon"></slot>
</div>
<input id="input-field" formControlName={this.formControlName} type={this.type} />
</div>
);
}
}
The documentation on Stencil is not very thorough on how to approach this.
Essentially, I am wanting to use my own custom Stencil input element in an Angular reactive form.