我想升級要在ng2組件內使用的ng1組件。NgUpgrade:升級Angular1組件時無法使用templateUrl
如果我只使用ng1組件的模板字符串進行升級,它將起作用。但是,如果我切換到使用一個templateUrl相反,應用程序崩潰,給我這個錯誤:
angular.js:13920 Error: loading directive templates asynchronously is not supported
at RemoteUrlComponent.UpgradeComponent.compileTemplate (upgrade-static.umd.js:720)
at RemoteUrlComponent.UpgradeComponent (upgrade-static.umd.js:521)
at new RemoteUrlComponent (remote-url.component.ts:11)
at new Wrapper_RemoteUrlComponent (wrapper.ngfactory.js:7)
at View_AppComponent1.createInternal (component.ngfactory.js:73)
at View_AppComponent1.AppView.create (core.umd.js:12262)
at TemplateRef_.createEmbeddedView (core.umd.js:9320)
at ViewContainerRef_.createEmbeddedView (core.umd.js:9552)
at eval (common.umd.js:1670)
at DefaultIterableDiffer.forEachOperation (core.umd.js:4653)
下面是一個展示普拉克我的問題:
https://plnkr.co/edit/2fXvfc?p=info
我跟着角1 - > 2升級指南,似乎這個代碼應該工作。我不太確定它爲什麼不起作用。
我試過你的方法,但我得到這個錯誤,而不是:您即將從您的角度指令升級,例如templateUrls的 '未捕獲的ReferenceError:要求未在VM586 remoting-定義 url.component.js:8' – Houa
要使用'require'you必須使用正確的模塊加載程序,在這種情況下,我認爲使用commonJS的更多細節.. https://stackoverflow.com/questions/19059580/client-on-node-uncaught-referenceerror-需要 - 是 - 不定義 – Florian