I have components that need to be flexible for other areas of my site and so far am thinking using
*ngIf
to toggle the necessary child component linking to the route would be the easiest way to go about achieving it.
To be more precise, I have two sections, one I call the "Rebranding" section and the other the "Brand a New Business" section. I have 1 point I want to make to them both in two different ways. Which I'm encompassing in a "Fresh Start" component.
A "fresh start" for someone who's been in Business for 6 years is different from a "fresh start" for someone who's starting a new Business, therefor there's different key points I want to touch on.
The reason I want to keep them housed in one component is because in the long run I can see it being easier to manage each "point" I want to make for each crowd I want to communicate it to. I figured that would be cleaner and easier than having that many components all scattered around and wired into the routing.
So far this is what I've been able to muster up for the area of my site I'm on now.
import { Component } from '@angular/core';
import { Router } from '@angular/router';
@Component({
selector: 'asset-packs',
template: `<h1>Asset Packs</h1>
<asset-expand *ngIf="router.urlTree.contains(router.createUrlTree(['/expand']))"></asset-expand>
`,
directives:[
Router
]
})
export class PointAssetsComponent {
constructor(private router: Router){};
}
I have it all routed up in the module and didn't get any errors prior to trying this method. I came across it on another answer on here that really didn't give much clarity in terms of what components I needed to import. With that being said I already know this is incomplete, wasn't sure of where to add the constructor, I tried it both on top and bottom, not sure if I'm even using the router correctly. without the *ngIf everything shows up perfectly fine. I figured I'd start out with one nested component to make sure it shows up where I want it to and stays off on the other pages that use this component. This in particular is for the "assets" component, which will be featured in 3 sections, but 2 of them will be the same, which means I'm also going to need to use an "or" statement or throw a "!" in there.