问题标签 [angular8]

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 投票
1 回答
2501 浏览

typescript - 使用 Type Script/Angular 8 拖放或选择文件

如何使用打字稿使用 ng-upload-file 插件:

https://github.com/danialfarid/ng-file-upload

我也很累,但它不工作,任何工作样本都一样。或任何其他具有拖放/选择文件功能和开源的插件。

0 投票
2 回答
3293 浏览

angular - 更新 Angular 7 -> Angular 8 时出错

一个月前,我开始了一个 Angular 7 项目。现在我需要将 Angular Material 包含到项目npm i中。它最近发布的版本 8 似乎与 Angular 7 不兼容。

所以我开始更新 Angular 7 → Angular 8: ng update @angular/cli @angular/core。这给了我一个错误:

在本指南https://update.angular.io/#7.0:8.0我发现:

“一旦您和您的所有依赖项都更新到 RxJS 6,请删除 rxjs-compat。”

我应该在 rxjs^6 上。我需要rxjs-compat能够使用我swagger client生成的https://github.com/swagger-api/swagger-codegen。我试图"rxjs-compat": "^6.5.2"从 package.json 中删除,但没有运气。

包.json:

所以我的目标是:

  1. 可以Angular Material v8在项目中使用
  2. 更新到Angular v8
  3. 继续使用生成的 Swagger 客户端
0 投票
1 回答
6313 浏览

angular - Angular 8 启用常春藤错误 - FirebaseModule 的 NgModule.importss 中位置 0 的值不是参考:[object Object]

我在 github 中有一个 repo,你可以在这里看到,我正在尝试启用 Ivy,但还没有运气。

显示的错误是:

重现步骤:

  1. 克隆 repo:https ://github.com/Ismaestro/angular8-example-app.git 。
  2. 在这个文件中 tsconfig.browser.ts像这样启用 Ivy:

    /li>
  3. 跑:

    /li>

我不知道该怎么办... :D

谢谢!!

伊斯玛

0 投票
2 回答
765 浏览

angular - 可以根据角度条件进行路由吗?

我有用于在角度应用程序中路由的动态配置,如下所示。

在上面的代码中,我基于动态值进行导航。如果第二个 url 以数字形式出现意味着它应该转到一个组件,而它作为字符串出现意味着它应该转到另一个组件。基于此,它应该路由。这是我的要求。这是否可以实现。

它可以基于路由条件吗?

是否支持其他基于条件的路由?就像 ASPNET 核心一样。请检查以下图片。

ASP.NET Core 路由约束

0 投票
1 回答
133 浏览

typescript - RXJS v6.4 switchMap 操作符返回一个 Observable 而不是结果(根据 TypeScript linter)

我正在运行一个 Angular 8 应用程序,我收到一个错误,这似乎是 RxJS 中的一个主要错误,或者我遗漏了一些东西。

现在我希望订阅者收到以下输出:

但相反,它输出了我在 switchMap 操作中返回的实际可观察​​对象:


概括

本质上,switchMap 似乎返回了一个类型的值,Observable<Observable<number>>而不仅仅是Observable<number>.

我不确定这是 TypeScript 还是 RxJS 错误,但似乎当我将 RxJS 恢复到 6.0.0 版本时,问题就消失了。


版本:

  • 角 8.0.0
  • 打字稿 3.4.5
  • RxJS 6.4.0

我刚刚测试过,同样的事情正在发生flatMap

0 投票
4 回答
342 浏览

javascript - Is there a way to replace today date with hours?

I'm building this app that get articles from a DB and 1 of the fields is the date which right now is in format '2019-06-13T18:03:58.000Z' and basically what I need to do is check if this is today's date return onyl the hours and am/pm so for this example is today so return 18:03pm, if the date is the same as yesterday's then return 'yesterday'and if the date is other than those then return 'Month, day'

I've tried creating Date objects and then compare but it didn't work

I have this code for the html:

and in the component.ts file:

I need to return the converted date in that function so my html code prints the correct formated date how can I do this?

0 投票
1 回答
771 浏览

angular - 在网格的子组件中设置选定的值。角 2+

使用 Angular 8 和 TypeScript。我有一个带有许多内部组件的网格,其中一个是<ng-select/>

数据绑定在子组件中完成 OnInit。当数据加载初始化时,我看到所有值和过滤器按预期工作,但它没有显示为选定项。从视觉上看,它看起来像是显示在 AAA - 绿色行中。一旦我触摸并释放下拉菜单,就会选择正确的值。

网格选择组件

父组件代码:

选择组件代码:

0 投票
1 回答
34 浏览

angular - 有没有办法在 Anguar 8 中全局导入服务或文件?

我以前用过 Swift,在 Swift 中你不需要做任何额外的事情就可以在任何地方使用任何类和常量。所以有没有办法在不使用角度的情况下做同样的事情import {someService} from '...path'

0 投票
1 回答
1035 浏览

angular - 当表单控件值在角度 8 中更改时,复选框检查状态在运行时不会更改

我有一个简单的应用程序,它有一个复选框和一个按钮。当我单击按钮时,将启动一个计时器,并且在每 1 秒循环中,它应该将复选框检查状态更改为选中和未选中。

为了确保绑定的 formControl 的值正常工作,我添加了一个文本框,并将相同的 formControl(isActive) 绑定到该文本框。

我的问题是:文本框上的值反复更改为“true”和“false”,但复选框选中状态没有改变。

我的 app.component.html 看起来像这样。

我的 app.component.ts 看起来像这样。

我的 app.module.ts 看起来像这样

请在stackblitz中查看我的项目

0 投票
2 回答
1807 浏览

ng-modules - Angular 8:没有为组件找到组件工厂-甚至在 app.module.ts 中添加

我正在尝试将项目从 Angular 7 迁移到 Angular 8。

但是,升级到 Angular 8 后,HeaderComponent 出现以下错误。

zone.js:199 未捕获的错误:找不到 HeaderComp 的组件工厂。你把它添加到@NgModule.entryComponents 了吗?在 NoComponentFactoryError (core.js:17988) 在 CodegenComponentFactoryResolver.push../node_modules/@angular/core/fesm5/core.js.CodegenComponentFactoryResolver.resolveComponentFactory (core.js:18026) 在 CodegenComponentFactoryResolver.push../node_modules/@angular /core/fesm5/core.js.CodegenComponentFactoryResolver.resolveComponentFactory (core.js:18023) 在 AngularFrameworkComponentWrapper.push../node_modules/ag-grid-angular/dist/angularFrameworkComponentWrapper.js.AngularFrameworkComponentWrapper.createComponent (angularFrameworkComponentWrapper.js:65)在 DynamicAgNg2Component.createComponent (angularFrameworkComponentWrapper.js:44) 在 DynamicAgNg2Component.push..

请在下面找到 HeaderComponent 和 app.module.ts。

这是针对 Angular 8 的,所以它在 Angular 7 中工作,在我在 Google 上搜索后,我通过声明 entryComponent 改进了 app.module.ts。

HeaderComponent.ts:

app.module.ts:

我希望它可以在 Angular 8 中工作,但它会抛出“找不到 HeaderComp 的组件工厂”。错误。

请帮我找到解决方案。

谢谢,

亲切的问候。

贝古姆