The instructions in the Angular routing documentation - Add heroes functionality mention making some adjustments:
Several changes need to be made:
-Remove the selector (routed components do not need them). -Remove the <h1>.
Is it beneficial to keep the selector in place so that the component can be used in both routing and non-routing scenarios?
Are there any disadvantages to keeping it in place?
In the documentation examples, components used in demos indeed remove the selector within the @Component
decorator as shown in the example of CrisisCenterComponent
below (Directly from the router documentation):
import { Component } from '@angular/core';
@Component({
template: `<p>Welcome to the Crisis Center</p>`
})
export class CrisisCenterHomeComponent { }
Imagine we move CrisisCenterComponent
to a shared module and utilize the component in multiple views/pages where sometimes the element name (Selector) is needed and other times the router. Removing the selector
would prevent this, correct?