问题标签 [angular-hybrid]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
98 浏览

angular - 在 webstorm 中的混合 Angular 应用程序中调试打字稿文件

我有一个 angular.js 和 angular 7 的混合应用程序。Angular.js 由 .js 和一些 .ts 文件组成。我已经使用 UpgradeModule 升级了 angular.js 应用程序。所有 angular.js src 文件都列在 angular.json 配置文件的脚本数组中(包括编译的 .ts 文件的路径,但扩展名为 .js)。问题是 webstorm 无法命中 angular.json 的脚本数组中列出的 .ts 文件的断点,因此无法在 WebStorm 中为此类文件设置调试器。

虽然从 Angular 7 创建的打字稿文件(如(app.component.ts))正在像往常一样被调试,并通过 WebStorm 达到断点。

我的 tsconfig.json 启用了源映射,我也尝试将 inlineSources 启用为 true,并且 "inlineSourceMap": true 以及它的不同组合,但它们都不起作用。

我的 webStorm 调试器设置调试器设置

我在用着

从 Angular 7 创建的打字稿文件是调试的

也许有人可以建议如何在 webstorm 中为这种文件配置调试器?

0 投票
1 回答
361 浏览

angular-hybrid - 如何在使用混合路由时以角度使用 ActivatedRoute?

我正在尝试使用升级模块从混合应用程序的角度组件中的路由(/item/{id:[^/]*}/')获取数据

我试过 ActivatedRoute 来推迟路由器状态,但它一直抱怨路由配置无效。

路由“”配置无效:路由必须指定路径或匹配器;区域:; 任务:Promise.then;值:错误:路由''的配置无效:路由必须指定路径或匹配器

0 投票
1 回答
1892 浏览

angular - Angular 混合应用程序测试“无法读取 null 的属性‘nativeElement’”

我有一个简单的测试:

并不断收到错误:

我试过使用tick()with like 20000,并添加fixture.detectChanges()但没有任何效果。另一项检查是否单击按钮和调用的函数的测试具有相同的错误。是不是找不到元素?

这个测试使用的所有东西都在 Angular 中,所以我不认为这是因为它是一个混合应用程序。

提前致谢。

0 投票
0 回答
78 浏览

angular - 在 initializeBindings 期间尝试使用 UpgradeComponent 会导致 TypeError

我遇到了一个问题,当我尝试在 angular 2 内使用 angularJS 组件时,在UpgradeComponent.initializeBindings遇到此错误的方法期间:

我相信它可能正在尝试在 Angular 中构建组件,但是从 angularJS 代码复制绑定时遇到了问题。我在下面包含了我的 JS 组件定义,有人可以提供任何帮助吗?

0 投票
1 回答
93 浏览

angularjs - 删除降级 angular 2 组件属性周围的单引号会导致奇怪的行为

我有一个降级的 Angular 2 组件,它在 AngularJS 组件中运行良好,直到我删除了组件第二个属性周围的单引号。

编辑:这个组件使用的文件类型是 ng.jade 。

这有效:

这不会:

在第二个示例中,false 应用于rating-score并且form-is-disabled未定义。我很好地将单引号留在周围,form-is-disabled但是在对混合应用程序进行了一些研究之后,我无法弄清楚单引号在这里做了什么。

为什么第二个属性 ( ) 需要它们,form-is-disabled而不是第一个 ( rating-score)?

0 投票
0 回答
578 浏览

javascript - 在我将 angualr 5 更新为 7 之后,同时在 angular 1.x 中运行 angular 5 时,无法实例化模块 $$UpgradeModule?

Angular 1.x 和 Angular 5 在我们的项目中一起运行,我只是将 Angular 5 升级到 7,留下 Angular 1.x 部分。我试图让 1.x 和 7 同时工作。这就是我遇到这个问题的地方,

错误是:

错误:无法实例化模块 $$UpgradeModule 由于:[$injector:modulerr]

它说我可能没有ngRoute在我的项目中安装,我检查了,我准备好了一切。有谁知道发生了什么?

0 投票
1 回答
92 浏览

angularjs - Angular 混合应用程序,具有模板功能的升级组件未收到 $element 或 $attrs

正如标题所说,我正在使用 Angular Hybrid 应用程序。我有一个旧的 AngularJS 组件,它使用一个template函数根据传入的输入动态构建自身。

我已经将该组件升级为可以从 Angular 使用,但是template它的功能不再起作用,因为$element并且$attrs没有正确地注入到该template功能中。

这是一个显示问题的简单堆栈闪电战

如您所见,当直接从 AngularJS 使用组件时,它被正确地赋予了$element$attrs值,但是当将它渲染为从 Angular 升级的组件时,它却没有。有什么方法我应该为升级的组件手动提供这些吗?

0 投票
1 回答
553 浏览

angularjs - Not recognized camelcase parameters in downgraded component in an Angular hybrid application

I have a angularjs 1.6 that has just been configured to have hybrid bootstrap with angular 8.

I created 2 new components DriverDetail and DriverDetailLine both in angular 8:

DriverDetail is downgraded to be used from angularjs like this:

When DriverDetailLine is used inside DriverDetail passing the titleKey input parameter:

This error is produced:

Uncaught Error: Template parse errors: Can't bind to 'title-key' since it isn't a known property of 'driver-detail-line'. 1. If 'driver-detail-line' is an Angular component and it has 'title-key' input, then verify that it is part of this module. 2. If 'driver-detail-line' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. 3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. (" test ][title-key]="'DRIVER_DASHBOARD.IN_TRANSIT'" [icon]="'directions_car'"> {{ 'LABEL"): ng:///DriverDetailModule/DriverDetail.html@0:51 at syntaxError (compiler.js:2687) at TemplateParser.parse (compiler.js:12254) at JitCompiler._parseTemplate (compiler.js:27526) at JitCompiler._compileTemplate (compiler.js:27513) at eval (compiler.js:27456) at Set.forEach () at JitCompiler._compileComponents (compiler.js:27456) at eval (compiler.js:27366) at Object.then (compiler.js:2678) at JitCompiler._compileModuleAndComponents (compiler.js:27365)

Note that the components work correctly if the camel case parameter is not used, or if its name is changed to a non-camel case name.

Have also tried in other formats like:

But also got a similar error

The same happens when trying to use a third party component, when using a parameter in camel case it will produce the same error.

Many thanks, Miguel

Edit for more information:

0 投票
1 回答
1139 浏览

angularjs - 构建混合 angular/angularjs 应用程序 - 如何在 angularjs 应用程序中加载 angular 模块

我想开始在使用 gulp 构建的现有 angularjs 项目中使用 Angular 组件,并希望downgradeModule用于创建混合 Angular/AngularJS 应用程序。

我在使用 gulp 捆绑 AngularJS 应用程序时从 Angular 项目中导入 AppModule 时遇到问题 - browserify 步骤抱怨找不到 AppModule:

模块在 AngularJS 入口文件中是这样导入的:

我想知道如何使用该ng build命令单独构建 Angular 应用程序,然后在捆绑 angularjs 应用程序时使编译的 AppModule 可见。

我想我可以ng build在 gulp 任务中调用命令并将工件复制到 AngularJS dist 文件夹:

但我不确定在导入模块时如何解析 AppModule 的路径:

0 投票
1 回答
240 浏览

angular - Angular CLI 不会为生产模式下的降级模块生成代码

我想开始在现有angularjs项目中使用 Angular 组件,并希望使用它downgradeModule来创建混合Angular/AngularJS应用程序。

我已经能够angular使用 main.ts 文件中的代码降级我的组件:

ng build虽然使用and命令时一切正常ng serve,但 prod 模式存在问题 -我运行时未生成编译js代码(我无法将其视为编译文件的一部分)。AppModuleng build --prodmain.{hash}.js

我怀疑这是由于按需引导的事实,AppModule但我不知道如何解决这个问题并让这个模块编译。

目前,由于尚未编译 AppModule,我的 angularjs 应用程序中出现此错误