I have the following question:
Today, as far as I can see, there is a way to receive information in a Component of the Angular.
But I am in doubt about the "performance" issue.
The following example I do the import of the package "@ angular / core":
import { Component, Input } from '@angular/core';
@Component({
selector: 'app-meu',
template: '<h1>Meu nome é {{ meuNome }}</h1>'
})
export class MeuComponent {
@Input('nome') meuNome: string = '';
constructor() {}
}
In the example below I do the same thing without the need to import
import { Component } from '@angular/core';
@Component({
selector: 'app-meu',
template: '<h1>Meu nome é {{ meuNome }}</h1>',
inputs: ['meuNome:nome']
})
export class MeuComponent {
meuNome: string = '';
constructor() {}
}
In both cases I would be able to use my component, passing the [nome]
attribute and it would work.
But using @Input()
I find it more elegant and easier to orient in the development of what is input property or what is variable in my class.
Then comes the doubt, does using @Input()
make the code slower? What is the best practice?