asp.net mvc - How to handle repetitive HTML code such as headers and footers in Angular 4? -
in angular web project use different 2 or 3 types of header in many pages in angular 4 project. there way code html header code , footer code once , have included or injected in 1 or more of pages. give clue need alternative @section in asp.net mvc razor witch in each page can add code (i know server side thing, need in angular client side). there official/recommended way this?
you should create components that. like:
@component({ selector: 'myheader', templateurl: './header.component.html', styleurls: ['./header.component.scss'] }) export class headercomponent implements oninit { ...
and add template of other pages want use (or app.component.html if want everywhere). like:
<myheader></myheader>
if need different data on header depending on component at, create headerservice, , pass data header component through it.
Comments
Post a Comment