페이지에 오류를 포함하여 구성 요소 및 내 페이지에 포함하고 싶지만 작동하지 않습니다 entryComponents
및 declarations
섹션의 app.module.ts
이온 2 : 오류 메시지가 나는 이미에 구성 요소를 추가</p> <pre><code>No provider for MyExample </code></pre> <p>나타납니다 때문에이 구성 요소를 만든
내 예를 들어, 구성 요소SRC/응용 프로그램/구성 요소/내 - 예/내 - example.ts
import { Component } from '@angular/core';
@Component({
selector: 'my-example',
templateUrl: 'my-example.html'
})
export class MyExample {
constructor() {
console.log('Constructor...');
}
}
app.module.tsSRC/응용 프로그램/app.module.ts
import { MyExample } from '../components/my-example/my-example';
@NgModule({
declarations: [MyExample],
bootstrap: [IonicApp],
....
entryComponents: [MyExample]
})
내 페이지SRC/응용 프로그램/PA GES/마이 페이지/내 - page.ts
import { MyExample } from '../../components/my-example/my-example';
@Component({
selector: 'purchase-page',
templateUrl: './purchase.html'
})
......
app.module.ts에 내가 console.log(MyExample);
와 구성 요소의 내용을 표시 할 수 있으며 완벽하게 작동하고 있기 때문에 경로가 올바른지.
Ionic 2 RC4를 사용하고 있습니다.
친절에 감사드립니다!
내에서 구성 요소를 포함하여 그것을 고정? –
purchase.html에서 ie : my-example을 선언 한 셀렉터를 사용하여 컴포넌트를 직접 사용할 수 있습니다. 또한 도움이 될 수있는 추가 코드를 보여줄 수 있다면. – Jayesh
@ViewChild 내의 구성 요소를 포함하여 수정했습니다. – SoldierCorp