Created
October 8, 2017 12:21
-
-
Save bennadel/7bc7a94268a6e4f710abb76c8411c73b to your computer and use it in GitHub Desktop.
Routable View Components Don't Need Selectors In Angular 4.4.4 - But They May Be Helpful
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import the core angular services. | |
import { Component } from "@angular/core"; | |
// ----------------------------------------------------------------------------------- // | |
// ----------------------------------------------------------------------------------- // | |
@Component({ | |
// NOTE: Since routable views aren't embedded in template logic, we don't need to | |
// provide a SELECTOR - Angular will inject this component automatically as part | |
// of the router-outlet logic (using the "ng-component" tag). | |
styleUrls: [ "./a-view.component.css" ], | |
template: | |
` | |
<h3> | |
A-View Component | |
</h3> | |
<p> | |
This is the a-view component, noice! | |
</p> | |
` | |
}) | |
export class AViewComponent { | |
// ... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import the core angular services. | |
import { Component } from "@angular/core"; | |
// ----------------------------------------------------------------------------------- // | |
// ----------------------------------------------------------------------------------- // | |
@Component({ | |
// For this routable component, we're going to include a SELECTOR even though it | |
// isn't strictly necessary (so that we can see how the view output is affected). | |
selector: "b-view", | |
styleUrls: [ "./b-view.component.css" ], | |
template: | |
` | |
<h3> | |
B-View Component | |
</h3> | |
<p> | |
This is the b-view component, sweet! | |
</p> | |
` | |
}) | |
export class BViewComponent { | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment