Angular 2 アプリ (ベータ 1) に ComponentB があります。ComponentA の ngFor ループ内に配置するまで、完全に正常に動作します。次のやや不可解なエラーが表示されます。
例外: TypeError: viewFactory_ComponentB0 is not a function in [ComponentA@1:23 の数字]BrowserDomAdapter.logError @ angular2.dev.js:22690BrowserDomAdapter.logGroup @ angular2.dev.js:22701ExceptionHandler.call @ angular2.dev.js:1163 (匿名関数) @ angular2.dev.js:12416NgZone._notifyOnError @ angular2.dev.js:13324collection_1.StringMapWrapper.merge.onError @ angular2.dev.js:13228run @ angular2-polyfills.js:141(匿名関数) @ angular2 .dev.js:13247NgZone.run @ angular2.dev.js:13209(匿名関数) @ angular2.dev.js:12499schedulerFn @ angular2.dev.js:12742tryCatcher @ Rx.js:31Subscriber.next @ Rx.js:9500Subject ._next @ Rx.js:9999Subject.next @ Rx.js:9963EventEmitter.emit @ angular2.dev.js:12723(匿名関数) @ angular2.dev.js:13140run @ angular2-polyfills.js:138NgZone._notifyOnTurnDone @ angular2 .dev.js:13139(匿名関数) @ angular2.dev.js:13254zoneBoundFn @ angular2-polyfills.js:111lib$es6$promise$asap$$flush @ angular2-polyfills.js:1305 angular2.dev.js:22690 元の例外: TypeError: viewFactory_ComponentB0 は functionBrowserDomAdapter.logError @ angular2.dev.js:22690ExceptionHandler.call @ angular2.dev.js:1172(匿名関数) @ angular2.dev.js:12416NgZone._notifyOnError @ angular2.dev.js:13324collection_1.StringMapWrapper ではありません。 merge.onError @ angular2.dev.js:13228run @ angular2-polyfills.js:141(匿名関数) @ angular2.dev.js:13247NgZone.run @ angular2.dev.js:13209(匿名関数) @ angular2.dev. js:12499schedulerFn @ angular2.dev.js:12742tryCatcher @ Rx.js:31Subscriber.next @ Rx.js:9500Subject._next @ Rx.js:9999Subject.next @ Rx.js:9963EventEmitter.emit @ angular2.dev.js: 12723 (匿名関数) @ angular2.dev.js:13140run @ angular2-polyfills.js:138NgZone._notifyOnTurnDone @ angular2.dev.js:13139(匿名関数) @ angular2.dev.js:13254zoneBoundFn @ angular2-polyfills.js:111lib$es6$promise$asap$$flush @ angular2 -polyfills.js:1305 angular2.dev.js:22690 元のスタックトレース:BrowserDomAdapter.logError @ angular2.dev.js:22690ExceptionHandler.call @ angular2.dev.js:1175(匿名関数) @ angular2.dev.js:12416NgZone. _notifyOnError @ angular2.dev.js:13324collection_1.StringMapWrapper.merge.onError @ angular2.dev.js:13228run @ angular2-polyfills.js:141(匿名関数) @ angular2.dev.js:13247NgZone.run @ angular2.dev. js:13209(匿名関数) @ angular2.dev.js:12499schedulerFn @ angular2.dev.js:12742tryCatcher @ Rx.js:31Subscriber.next @ Rx.js:9500Subject._next @ Rx.js:9999Subject.next @ Rx. js:9963EventEmitter.emit @ angular2.dev.js:12723(匿名関数) @ angular2.dev.js:13140run @ angular2-polyfills.js:138NgZone._notifyOnTurnDone @ angular2.dev.js:13139(匿名関数) @ angular2.dev.js:13254zoneBoundFn @ angular2-polyfills.js: 111lib$es6$promise$asap$$flush @ angular2-polyfills.js:1305 angular2.dev.js:22690 TypeError: viewFactory_ComponentB0 is not a function at AppElement.viewFactory_ComponentA1 [as embeddedViewFactory] (viewFactory_ComponentA:388) at AppViewManager_.createEmbeddedViewInContainer ( angular2.dev.js:9185) で ViewContainerRef_.createEmbeddedView (angular2.dev.js:5890) で NgFor._bulkInsert (angular2.dev.js:14608) で NgFor._applyChanges (angular2.dev.js:14567) で NgFor. AbstractChangeDetector.ChangeDetector_ComponentA_0.detectChangesInRecordsInternal (viewFactory_ComponentA:45) AbstractChangeDetector.detectChangesInRecords (angular2.dev.js:7825) で AbstractChangeDetector.runDetectChanges (angular2.dev.js:7808) で AbstractChangeDetector._detectChangesInViewChildren (angular2.dev.js:7892) で
コンポーネント A:
@Component({
selector: 'component-a'
, directives: [
FORM_DIRECTIVES
, ComponentB
]
, template: `
<!-- works --><component-b [(ngFormControl)]="_formControl"></component-b>
<!-- fails --><component-b *ngFor="#number of numbers" [(ngFormControl)]="_formControls[number]"></component-b>
`
})
export class ComponentA {}
ヒント/ヘルプは大歓迎です。