2017-02-06 44 views
2

我有一個使用JavaScriptServices starter創建的Angular2應用程序。使用JavaScriptServices/Universal時出現Angular2表單錯誤

我遇到的問題是,如果我在組件中有窗體,會得到運行時錯誤。

我正在導入FormsModuleReactiveFormsModule

我的形式看起來像這樣...

<form (ngSubmit)="onSubmit()" #loginForm="ngForm" > 
... 
</form> 

我得到的錯誤是...

Exception: Call to Node module failed with error: Prerendering failed because of error: TypeError: _angular_core.InjectionToken is not a constructor at C:\XXX\ClientApp\dist\main-server.js:35055:42

有什麼我錯過了?當我不使用JavaScriptServices入門進行服務器端渲染時,我的表單設置完美運行。

回答

0

我找到了解決方案。我使用的是最新版本的Angular。它還不兼容。

閱讀本GitHub的問題頁面後,我發現,恢復的角度版本解決了該問題https://github.com/angular/angular/issues/13432

我現在用下面的版本,一切似乎都很好。

"@angular/common": "2.0.2", 
"@angular/compiler": "2.0.2", 
"@angular/core": "2.0.2", 
"@angular/forms": "2.0.2", 
"@angular/http": "2.0.2", 
"@angular/platform-browser": "2.0.2", 
"@angular/platform-browser-dynamic": "2.0.2", 
"@angular/platform-server": "2.0.2", 
"@angular/router": "3.0.2", 
相關問題