2016-01-26 28 views
0

我有一個簡單Angular2應用,其中包含AppP1P2Child總共4層的組件,其中App使用P1P2,並且兩個P1P2用途Child不能注入可重複使用的組件不同的組件以相同的電平在Angular2

下面是代碼:

@Component({ 
    selector: 'child', 
    template: '<div> child <div>', 
}) 
export class ChildCmp {} 

@Component({ 
    selector: 'p1', 
    template: '<div> P1: <child></child></div>', 
    directives:[ChildCmp], 
}) 
export class P1Cmp {} 

@Component({ 
    selector: 'p2', 
    template: '<div> P2: <child></child><child></child></div>', 
    directives:[ChildCmp], 
}) 
export class P2Cmp {} 

@Component({ 
    selector: 'my-test', 
    template: '<p1></p1><p2></p2>', 
    directives:[P1Cmp, P2Cmp], 
}) 
export class TestApp {} 

bootstrap(TestApp); 

的index.html觸發的應用程序是純<my-test></my-test>所有必需Angular2的庫。

您可以查看演示在Plunker,控制檯日誌顯示Angular2初始化

EXCEPTION: TypeError: viewFactory_ChildCmp0 is not a function 

這個應用程式的空檔,一旦我把Child到兩個P1P2,然後它打破。

任何想法爲什麼它打破?

回答

3

首先,使用Angular 2 beta.1的unminified版本,有很好的文檔說明他們有.min.js版本的問題。其次,避免beta.1現在,你的例子工作完美beta.0

+0

只是厭倦了未分類的版本,它仍然打破,它確實與beta.0,所以它是beta.01中的錯誤?謝謝! – resec

+0

然而,它是。你的代碼非常好。他們將從現在開始每週發佈新的Angular 2版本......敬請期待。 –

相關問題