加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – NgUpgrade:升级Angular1组件时无法使用templateUr

发布时间:2020-12-17 07:30:21 所属栏目:安全 来源:网络整理
导读:我想升级ng2组件以在ng2组件中使用. 如果我只使用模板字符串ng1组件,要升级,它的工作原理.但是,如果我切换到使用templateUrl,应用程序崩溃并给我这个错误: angular.js:13920 Error: loading directive templates asynchronously is not supportedat RemoteU
我想升级ng2组件以在ng2组件中使用.

如果我只使用模板字符串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

我跟着Angular 1 – > 2升级指南似乎这个代码应该工作.我不太清楚为什么它不起作用.

我找到了一个非常便宜的解决方案.

只需使用template:require(‘./ remote-url.component.html’)而不是templateUrl:’./ remote-url.component.html’,它应该可以正常工作!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读