2017-11-15 6 views
0

index.html 파일에서 <a routerLink="/Profile">Profile</a>을 사용하는 동안 문제가 있습니다. 앵커 태그가 제대로 작동하지 않았습니다. 나는 index.html을에 머리글 메뉴를 배치 할 때 내가 파일을 작업 app.component.html<a routerLink="#Profile">Profile</a> 각도 4에서 워킹되지 않습니다.

같은 줄의 코드 <a routerLink="/Profile">Profile</a>에 배치됩니다

<router-outlet></router-outlet> 각 4

<a href="#Profile" routerLink="/Profile" routerLinkActive="active"> 
<span class="icon-cogs"></span>Profile</a> 
에서 라우팅을 위해 다음 코드를 추가 할 다른 구성 요소에 넣지 만 index.html에서 작동하지 않습니다.

+0

는 또한'HREF를 제거 = " #Profile ". –

+0

프로젝트 구조를 제공해 주시겠습니까? –

답변

0

이 코드는 index.html 안에 넣지 마십시오. 작동하지 않으며 구성 요소 내에 있어야합니다. 그래서이 좋아 계속

routerLink="/Profile" 

을 :

routerLink이처럼 더 자세히 들어

<a routerLink="/Profile" routerLinkActive="active"> 

읽어보십시오

https://angular.io/guide/router

+0

여전히 작동하지 않습니다. whrn 나는 그것이 작동하는 모든 구성 요소에 동일한 코드를 넣습니다. – Faraz