0
我有一個簡單Angular2應用,其中包含App
,P1
,P2
,Child
總共4層的組件,其中App
使用P1
和P2
,並且兩個P1
和P2
用途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
到兩個P1
和P2
,然後它打破。
任何想法爲什麼它打破?
只是厭倦了未分類的版本,它仍然打破,它確實與beta.0,所以它是beta.01中的錯誤?謝謝! – resec
然而,它是。你的代碼非常好。他們將從現在開始每週發佈新的Angular 2版本......敬請期待。 –