Angular components are the small entities, that contains its own view, controller and associated style. They can be used within other components to build a collective view.
-
selector: A CSS selector that tells Angular to create and insert an instance of this component wherever it finds the corresponding tag in template HTML. For example, if an app's HTML contains<app-hero-list></app-hero-list>, then Angular inserts an instance of theHeroListComponentview between those tags.
-
templateUrl: The module-relative address of this component's HTML template. Alternatively, you can provide the HTML template inline, as the value of thetemplateproperty. This template defines the component's host view.
-
providers: An array of providers for services that the component requires. In the example, this tells Angular how to provide theHeroServiceinstance that the component's constructor uses to get the list of heroes to display.
Sample Angular Component
@Component({
selector: 'app-hero-list',
templateUrl: './hero-list.component.html',
providers: [ HeroService ]
})
export class HeroListComponent implements OnInit {
/* . . . */
}

0 Comments