我注意到从2.0.0.0-beta.0升级到2.0.0.0-beta.1
时出现问题下面的示例代码在beta.0(see plunkr 1)中正常运行,但在beta.1(see punkr 2)中没有。它由1个简单的虚拟组件和2个分组组件组成,每个组件包含该虚拟组件。我希望将这两个分组组件并排显示为兄弟姐妹:
import {Component} from 'angular2/core';
@Component({
selector: 'dummy-item',
template: 'Hi I am a dummy item!'
})
export class DummyItem {}
@Component({
selector: 'group-a',
directives: [DummyItem],
template:`
<div>
group A:
<dummy-item></dummy-item>
<dummy-item></dummy-item>
</div>
`
})
export class GroupA {}
@Component({
selector: 'group-b',
directives: [DummyItem],
template:`
<div>
group B:
<dummy-item></dummy-item>
<dummy-item></dummy-item>
</div>
`
})
export class GroupB {}
@Component({
selector: 'my-app',
template:`
<group-a></group-a>
<group-b></group-b>
`,
directives: [DummyItem, GroupA, GroupB]
})
export class AppComponent {}
我认为这是嵌套组件的常规方式,所以我没想到这会因为次要更新而中断。
我很想知道为什么会出现以下错误,以及如何防止它。我已阅读changelog,但无法从中获得解决方案。
这是stacktrace:
EXCEPTION: TypeError: viewFactory_DummyItem0 is not a functionBrowserDomAdapter.logError @ angular2.dev.js:22690
angular2.dev.js:22690 STACKTRACE:BrowserDomAdapter.logError @ angular2.dev.js:22690
angular2.dev.js:22690 TypeError: viewFactory_DummyItem0 is not a function
at viewFactory_GroupB0 (viewFactory_GroupB:88:1)
at viewFactory_AppComponent0 (viewFactory_AppComponent:88:1)
at HostViewFactory.viewFactory_HostAppComponent0 [as viewFactory] (viewFactory_HostAppComponent:75:1)
at AppViewManager_.createRootHostView (https://code.angularjs.org/2.0.0-beta.1/angular2.dev.js:9172:34)
at https://code.angularjs.org/2.0.0-beta.1/angular2.dev.js:12189:46
at Zone.run (https://code.angularjs.org/2.0.0-beta.1/angular2-polyfills.js:138:17)
at Zone.run (https://code.angularjs.org/2.0.0-beta.1/angular2.dev.js:13247:32)
at zoneBoundFn (https://code.angularjs.org/2.0.0-beta.1/angular2-polyfills.js:111:19)
at lib$es6$promise$$internal$$tryCatch (https://code.angularjs.org/2.0.0-beta.1/angular2-polyfills.js:1511:16)
at lib$es6$promise$$internal$$invokeCallback (https://code.angularjs.org/2.0.0-beta.1/angular2-polyfills.js:1523:17)
-----async gap-----
Error
at _getStacktraceWithUncaughtError (https://code.angularjs.org/2.0.0-beta.1/angular2-polyfills.js:2195:26)
at Zone.fork (https://code.angularjs.org/2.0.0-beta.1/angular2-polyfills.js:2253:40)
at Zone.bind (https://code.angularjs.org/2.0.0-beta.1/angular2-polyfills.js:109:48)
at bindArguments (https://code.angularjs.org/2.0.0-beta.1/angular2-polyfills.js:980:29)
at lib$es6$promise$promise$$Promise.obj.(anonymous function) [as then] (https://code.angularjs.org/2.0.0-beta.1/angular2-polyfills.js:1000:37)
at DynamicComponentLoader_.loadAsRoot (https://code.angularjs.org/2.0.0-beta.1/angular2.dev.js:12188:49)
at di_1.provide.useFactory (https://code.angularjs.org/2.0.0-beta.1/angular2.dev.js:12286:39)
at Injector._instantiate (https://code.angularjs.org/2.0.0-beta.1/angular2.dev.js:11297:19)
at Injector._instantiateProvider (https://code.angularjs.org/2.0.0-beta.1/angular2.dev.js:11230:21)
at Injector._new (https://code.angularjs.org/2.0.0-beta.1/angular2.dev.js:11220:19)
-----async gap-----
Error
at _getStacktraceWithUncaughtError (https://code.angularjs.org/2.0.0-beta.1/angular2-polyfills.js:2195:26)
at Zone.fork (https://code.angularjs.org/2.0.0-beta.1/angular2-polyfills.js:2253:40)
at NgZone._createInnerZone (https://code.angularjs.org/2.0.0-beta.1/angular2.dev.js:13235:39)
at new NgZone (https://code.angularjs.org/2.0.0-beta.1/angular2.dev.js:13101:32)
at createNgZone (https://code.angularjs.org/2.0.0-beta.1/angular2.dev.js:12308:12)
at PlatformRef_.application (https://code.angularjs.org/2.0.0-beta.1/angular2.dev.js:12383:31)
at Object.bootstrap (https://code.angularjs.org/2.0.0-beta.1/angular2.dev.js:24410:64)
at execute (http://run.plnkr.co/gclpu8pCsklPMCpi/app/boot.ts!transpiled:12:23)
at u (https://code.angularjs.org/tools/system.js:5:97)
at Object.execute (https://code.angularjs.org/tools/system.js:5:3188)