You must create a variable to receive the values within the Component. See this example:
@Component({
selector: 'app-button',
template: `
<button type="submit">{{label}}</button>
`,
})
export class AppButtonComponent {
@Input() label: string;
}
This will make you need to declare the variable label the moment you create the component, like this:
<app-button [label]="'Teste'"></app-button>
Note that I declared the name "Test" in single quotes, as I am declaring it manually. If it were another variable inside your other Komponent, you could pass the variable directly, without the need for quotation marks, like this:
<app-button [label]="minhaVariavel"></app-button>
Observing: You cannot declare anything within the declaration of app-button because, when rendering, Angular will replace what you manually declared with what was declared in the property template or templateUrl.
It’s not duplicated. This topic you mentioned teaches the basic component creation, which I claimed to know in this topic. In case my question is about how to dynamically insert HTML into the component.
– Wallace Magalhães
In the example template:
<button type="submit">{{name}}</button>, in HTML<app-button name="ENVIAR"></app-button>, in the add Component within the class@Input() name:string;and importInput– NoobSaibot