标签: angular6

Angular v6,rxjs v6错误TS2339:类型'OperatorFunction上不存在属性'pipe'

我已经使用rxjs-lint包和以下命令使用新的管道方法更新了Angular 5.5/rxJS5.5以及Angular 6/rxJS6的代码

npm i -g rxjs-tslint
rxjs-5-to-6-migrate -p tsconfig.json
Run Code Online (Sandbox Code Playgroud)

进口等已经按预期进行了修改,但是现在使用RxJS的Angular/5.5的v5工作正常的代码错误的错误:

 error TS2339: Property 'pipe' does not exist on type 'OperatorFunction<{}, {} | RouterEvent | RouteConfigLoadStart | RouteConfigLoadEnd | ChildActivati...'.
Run Code Online (Sandbox Code Playgroud)

我删除了rxjs6-compat包,但没有区别.这几乎就像构建认为它有一个早于rxJS的版本而不是v5.5. 与npm install一起使用的package.json看起来像这样......

"dependencies": {
    "@angular/animations": "^6.0.2",
    "@angular/cdk": "^6.0.2",
    "@angular/common": "^6.0.2",
    "@angular/compiler": "^6.0.2",
    "@angular/core": "^6.0.2",
    "@angular/flex-layout": "^6.0.0-beta.15",
    "@angular/forms": "^6.0.2",
    "@angular/http": "^6.0.2",
    "@angular/material": "^6.0.2",
    "@angular/platform-browser": "^6.0.2",
    "@angular/platform-browser-dynamic": "^6.0.2",
    "@angular/router": "^6.0.2",
    "@ngrx/effects": "^6.0.0-beta.3",
    "@ngrx/entity": "^6.0.0-beta.3",
    "@ngrx/router-store": "^6.0.0-beta.3",
    "@ngrx/store": "^6.0.0-beta.3",
    "@ngrx/store-devtools": "^6.0.0-beta.3",
    "@ngx-translate/core": "^9.0.1",
    "core-js": "^2.5.2",
    "hammerjs": "^2.0.8",
    "lodash": …
Run Code Online (Sandbox Code Playgroud)

angular6 rxjs6

4
推荐指数
2
解决办法
6733
查看次数

错误:未捕获(承诺):错误:无法匹配任何路由。网址段:“ site-notice”

我完全对此错误感到困惑。我有一个非常基本的简单路由:

const routes: Routes = [
    {
        path: '', component: FrameDefaultComponent, pathMatch: 'full',
        children: [
            {path: '', component: SiteCalculatorComponent},
            {path: 'site-notice', component: SiteSiteNoticeComponent}
        ]
    },
];
Run Code Online (Sandbox Code Playgroud)

当我单击菜单菜单项中的site-notice时,如下所示:

menuEntries = [
    {
        title: 'Calculator',
        url: '/'
    },
    {
        title: 'Site Notice',
        url: '/site-notice'
    }
];
Run Code Online (Sandbox Code Playgroud)

然后我得到以下错误:

core.js:1521 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'site-notice'
Error: Cannot match any routes. URL Segment: 'site-notice'
    at ApplyRedirects.push../node_modules/@angular/router/fesm5/router.js.ApplyRedirects.noMatchError (router.js:1359)
    at CatchSubscriber.selector (router.js:1340)
    at CatchSubscriber.push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchSubscriber.error (catchError.js:33)
    at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:80)
    at …
Run Code Online (Sandbox Code Playgroud)

angular-routing angular angular6

4
推荐指数
1
解决办法
9325
查看次数

如何使用垫片和角度材料自动完成保存所选对象2

我正在使用Angular 6和Angular Material.我试图从mat-chip和自动完成中保存所选对象或所选对象列表.我能够将字符串值发送到fruits []数组,但无法将所选对象发送到fruits []数组.请帮我找一个解决方案.谢谢.

我的演示项目链接:stackblitz上的演示代码

angular-material md-chip mat-autocomplete angular6 angular-material-6

4
推荐指数
2
解决办法
7827
查看次数

Angular 6 + Bootstrap 4全选并取消全选复选框

我在尝试使Bootstrap 4复选框与全选并取消选择6+中的所有选项时遇到问题。当我在此处使用原始代码时,它可以正常工作:http : //www.angulartutorial.net/2017/04/select-all-deselect-all-checkbox.html
但问题是Bootstrap使用其他事件单击他们的复选框。有人对此有解决方案吗?

<div class="form-check">
    <input class="form-check-input" type="checkbox" (change)="selectAll()">
    <label class="form-check-label">
        Select All
      </label>
</div>
<div class="form-check" *ngFor="let n of names">
    <input class="form-check-input" type="checkbox" value="{{n.name}}" [(ngModel)]="selectedNames" (change)="checkIfAllSelected()">
    <label class="form-check-label">
        {{n.name}}
      </label>
</div>
Run Code Online (Sandbox Code Playgroud)

和TS:

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-checkbox',
  templateUrl: './checkbox.component.html',
  styleUrls: ['./checkbox.component.scss']
})
export class CheckboxComponent implements OnInit {
  title = 'Checkbox';
  names: any;
  selectedAll: any;
  constructor() {
    this.title = "Select all/Deselect all checkbox - Angular 2";
    this.names = [
      { name: …
Run Code Online (Sandbox Code Playgroud)

html javascript bootstrap-4 angular6

4
推荐指数
1
解决办法
7645
查看次数

如何为角形材料的树组件应用样式

我正在为项目使用角材料的树组件。这是 stackblitz链接,在这里我需要实现两件事:

1)子元素的文本颜色必须在鼠标悬停时更改。

2)在单击/选择子元素时,必须更改背景颜色,背景颜色必须保持不变,直到我选择下一个子元素(如带有选择的列表)为止。

像这样

在此处输入图片说明

angular-material angular angular6

4
推荐指数
1
解决办法
3249
查看次数

Angular 6使用angular2-jwt

在我的应用程序从Angular 4 ^迁移到Angular 6(最新版本)后,我的Auth服务中出现了一个非常奇怪的错误.

具体而言,angular2,智威汤逊,当我尝试包导致一个杀手错误"serve"或"build"在应用production环境.另一方面,相同的代码在"dev"环境中运行得非常好.

操作系统 - > MacOS 10.13.6

执行时遇到的错误ng serve --configuration production:

ERROR in : Error: Internal error: unknown identifier [{"filePath":"/Users/paulo/Projects/eleo-usuario/node_modules/angular2-jwt/angular2-jwt.d.ts","name":"AuthHttp","members":[]},{"filePath":"/Users/paulo/Projects/eleo-usuario/node_modules/@angular/common/common.d.ts","name":"LocationStrategy","members":[]}]
at Object.importExpr$$1 [as importExpr] (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:21757:27)
at tokenExpr (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:11810:43)
at providerDef (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:11736:24)
at /Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:11906:81
at Array.map (<anonymous>)
at NgModuleCompiler.compile (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:11906:48)
at AotCompiler._compileModule (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:21702:36)
at /Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:21621:70
at Array.forEach (<anonymous>)
at AotCompiler._compileImplFile (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:21621:23)
at /Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:21611:74
at Array.map (<anonymous>)
at AotCompiler.emitAllImpls (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:21611:39)
at AngularCompilerProgram.generateFilesForEmit (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler-cli/src/transformers/program.js:736:46)
at AngularCompilerProgram._emitRender2 (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler-cli/src/transformers/program.js:330:27)
at …
Run Code Online (Sandbox Code Playgroud)

angular2-jwt angular angular6

4
推荐指数
1
解决办法
5928
查看次数

找不到模块:错误:无法解析'/ opt/lampp/htdocs/angular-testing-app/node_modules/jwa'中的'crypto'

我将在我的angular6项目中安装jsonwebtoken模块npm i jsonwebtoken.安装了jsonwebtoken模块Dependencies jwa,但是index.js文件加密需要错误无法解析'crypto',但我已经安装了crypto模块.

请帮助并解决问题.

我的错误:

ERROR in ./node_modules/jwa/index.js
Module not found: Error: Can't resolve 'crypto' in '/opt/lampp/htdocs/angular-testing-app/node_modules/jwa'
ERROR in ./node_modules/jws/lib/sign-stream.js
Module not found: Error: Can't resolve 'stream' in '/opt/lampp/htdocs/angular-testing-app/node_modules/jws/lib'
ERROR in ./node_modules/jws/lib/verify-stream.js
Module not found: Error: Can't resolve 'stream' in '/opt/lampp/htdocs/angular-testing-app/node_modules/jws/lib'
ERROR in ./node_modules/jws/lib/data-stream.js
Module not found: Error: Can't resolve 'stream' in '/opt/lampp/htdocs/angular-testing-app/node_modules/jws/lib'
Run Code Online (Sandbox Code Playgroud)

jwt angular6

4
推荐指数
2
解决办法
1663
查看次数

即使表单未通过验证,组件加载时反应形式的Angular 7设置值也会启用保存按钮

我有以下问题。单击以检查堆栈闪电。

我在构造函数中设置了反应形式:

this.formGroup = this.fb.group({
      'family_name_en': new FormControl('', Validators.required),
      'family_name_ar': new FormControl('', [Validators.required, Validators.pattern('[\u0600-\u06FF ]*')]),
      'unit_id': new FormControl({ value: '', disabled: true }, [Validators.required])
});
Run Code Online (Sandbox Code Playgroud)

而且ngOnInti(),我正在获取与关联的数据unit_id。

当我将数据从平台迁移到另一个平台时,不建议使用阿拉伯语的姓氏,但现在是这样。因此,大多数数据将不使用阿拉伯文名称加载。

问题是该按钮始终处于启用状态,而我需要做的是,如果用户要更新此unit_id按钮,则他应该添加阿拉伯语名称,以便随后启用该按钮。

如果表单有效,则启用按钮在加载组件时不会造成伤害。

这是getData()获取数据并设置表单组控件值的方法:

ngOnInit() {
    this.getDataById();
}
Run Code Online (Sandbox Code Playgroud)

getDataById():

getDataById() {
    this.showSpinner = true;
    this.auth.getDataById(this.unit_id).subscribe(
      (data) => {
        if (data['info'][0]['total'] == 1) {
          this.noDataBool = false;
          this.showSpinner = false;
          this.family_name_en = data['info'][0]['hh_last_name_en'];
          this.formGroup.controls['family_name_en'].setValue(this.family_name_en);
          this.family_name_ar = data['info'][0]['hh_last_name_ar'];
          this.formGroup.controls['family_name_ar'].setValue(this.family_name_ar);
          this.unit_id = data['info'][0]['unit_id'];
          this.formGroup.controls['unit_id '].setValue(this.unit_id);
    }
} …
Run Code Online (Sandbox Code Playgroud)

angular angular-reactive-forms angular6 angular7

4
推荐指数
1
解决办法
6467
查看次数

如何在页面加载时触发Toast?

我正在尝试使用<p-toast>登录页面中的A在用户登录时显示通知消息。

<p-toast position="top-center" key="tc"></p-toast>
Run Code Online (Sandbox Code Playgroud)

这些消息然后在我的组件中声明。

ngOnInit() {

    // add toasts
    this.messageService.addAll([
      {key: 'tc', severity: 'info', summary: '30 Nov 2020', detail: 'Important message 1'},
      {key: 'tc', severity: 'info', summary: '30 Nov 2020', detail: 'Important message 2'}
    ]);

    // do other stuff

}
Run Code Online (Sandbox Code Playgroud)

这行不通。为了确认我的吐司或消息没有问题,我将消息放置onClick()在页面上的一个事件中,并手动触发了该事件,该消息确实起作用。

如何获得吐司来代替页面加载?

primeng angular angular6

4
推荐指数
2
解决办法
561
查看次数

Angular-6:将字符串转换为自定义对象的数组

我有这个产生的字符串:

string str = [{"id":1,"name":"Angular"},{"id":2,"name":"SpringBoot"}]
Run Code Online (Sandbox Code Playgroud)

我想将其转换为Objects数组以使其具有:

listexps: Expertise[];
listexps = [{"id":1,"name":"Angular"},{"id":2,"name":"SpringBoot"}];
Run Code Online (Sandbox Code Playgroud)

而专门知识课程是

export class Expertise
{
    id: number;
    name: string;
}
Run Code Online (Sandbox Code Playgroud)

我尝试过:

let array = str .replace('[{','').replace('}]','').split("},{").map(String);
Run Code Online (Sandbox Code Playgroud)

但这并不能解决我的问题,我得到了:

"id":1,"name":"Angular","id":2,"name":"SpringBoot"
Run Code Online (Sandbox Code Playgroud)

代替

[{"id":1,"name":"Angular"},{"id":2,"name":"SpringBoot"}];
Run Code Online (Sandbox Code Playgroud)

您对解决这个问题有任何想法吗?非常感谢。

arrays json typescript angular angular6

4
推荐指数
1
解决办法
1099
查看次数