Correct way to solve application component in Angular 2

I am working on an application that pulls out a copy of my site based on a domain. I have an application working with one exception. I define the navbar and application footer in the app.component template as shown below.

    <navigation></navigation>
    <router-outlet></router-outlet> 
    <appFooter></appFooter>

And inside the template for appFooter and navigation, I process data using a safe navigator, as shown below

<p>{{copyService.copy?.somevalue}}</p>

What I really would like to do is use the data resolver and ActivatedRoute property to do something like this

var copy = this.route.snapshot.data['copy'];

in the application component. Then pass the data through the input variable to the footer and navigation.

Unfortunately, I'm not sure how I will deal with the solution for the application component when I redirect to my home component, for example below

{ path: '', redirectTo: '/home', pathMatch: 'full'},

- , , . .

, , , , , . , .

+4
1

, app.component.

{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: '', 
  component: BaseComponent, 
  resolve: { 
    yourContent: contentResolver 
  }, 
  children: [ 
  { path: 'home'... }
  ]
}

:

<navigation></navigation>
<router-outlet></router-outlet> 
<appFooter></appFooter>

base.html app.html

, BaseComponent, ( ).

, , .

+6

Source: https://habr.com/ru/post/1666673/


All Articles