在我的Angular 2應用程序中,我需要將數組從一個組件傳遞到另一個組件。我有一個名爲SystemDynamicsComponent
組件,公開了一個數組sdFactors
:異常self.context.XXX.subscribe不是函數
@Component({
selector: "system-dynamics",
templateUrl: "/app/component/main/template/system-dynamics.html"
})
export class SystemDynamicsComponent implements OnInit {
private dialogDisplayed: boolean = false;
@Output() sdFactors: any[] = [];
名爲InputModuleComponent
我需要如下讀取此值的組件:
模板:
<system-dynamics (sdFactors)="this.sdFactors"></system-dynamics>
組件:
export class InputModuleComponent implements OnInit {
...
sdFactors: any[] = [];
當launchig輸入模塊組件,我收到來自Angular的此錯誤消息: TypeError: self.context.sdFactors.subscribe is not a function at Wrapper_SystemDynamicsComponent.subscribe (wrapper.ngfactory.js:38) at View_InputModuleComponent6.createInternal (component.ngfactory.js:3103) at View_InputModuleComponent6.AppView.create (core.umd.js:12262) at View_InputModuleComponent6.DebugAppView.create (core.umd.js:12666) at TemplateRef_.createEmbeddedView (core.umd.js:9320) at ViewContainerRef_.createEmbeddedView (core.umd.js:9552)
任何想法我失蹤?
我改變了你的想法(''system-dynamics(sdFactors)=「sdFactors」> system-dynamics>'),但問題依然存在。 – Emdee
請看我的更新 –
問題解決了!按照您的建議,我現在使用'@ Input'。 – Emdee