What is the minimum definition of a component, After looking at https://angular.io/api/core/Component it seems all are optional. Can some one explain what is the minimum definition.
The absolute minimal configuration for a @Component in angular is a template.
Both template properties are set to optional because you have to define either template or templateUrl.
When you don't define them, you will get an exception like this;
No template specified for component 'ComponentName'
A selector property is not required, as you can also use your components in a route.
Minimum configuration for Component is a template,
template is required (either template or templateUrl)
import { Component } from '@angular/core';
@Component({
templateUrl: './minimum.component.html' // or
template: ''
})
export class MinimumComponent {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With