2016-11-21 2 views
-2

초보자는 각도 2로 만듭니다. 앱을 만들면 구성 요소가 첨부 된 그림과 같이 관련 폴더에 배치됩니다. 빌드에각도 2 부품 이름이 중복 됨

- app 
--components 
---users 
----create 
----edit 
---collaborations 
----create 
----edit 

오류 (역할 NG) : 오류를 [기본]

...\src\app\app.module.ts:9:9 Duplicate identifier 'CreateComponent'. 

가 어떻게이 문제를 해결할 수있는 구조인가? enter image description here

답변

0

CreateComponent을 두 번 가져오고 있습니다. 가져올 때 실제로 클래스를 추가하고 있습니다! 따라서 해당 구성 요소 파일 중 하나로 이동하여 구성 요소 클래스의 이름을 바꿉니다. 그런 다음 필수 입력란에서 변경하십시오.

첫 번째 구성 요소

export class FirstComponent implements OnInit { 

    constructor(private router: Router) { } 

    ngOnInit() { } 
} 

두 번째 구성 요소

이제
export class SecondComponent implements OnInit { 

    constructor(private router: Router) { } 

    ngOnInit() { } 
} 

을 가져올 수있는, 또한 당신이 당신의 선언에서 여러 번 호출

import { FirstComponent }       from "./first-component"; 
import { SecondComponent }       from "./second-component"; 

. 하나씩 전화해야합니다. 그 (것)들을 다르게 지명하고 각 선언을 선언에 추가하십시오.

+0

이름을 바꾸거나 이름이 다른 구성 요소를 만드는 것처럼 보입니다. 고칠 수있는 다른 방법이 있습니까? – Sami

+0

도움이 될 것입니다. https://github.com/angular/angular/issues/10538 – wuno