小编Lin*_*int的帖子

无法扩展接口“http.IncomingMessage”。您指的是 'implements' 吗?

我一直在努力运行serve我的 angular 项目,每次遇到一些错误时,我都尝试使用 google 寻找答案,现在达到了一个点,我没有找到任何有用的答案。我下载了一个MEAN堆栈应用程序并尝试运行,但现在出现以下错误

ERROR in ../node_modules/@types/connect/index.d.ts:21:42 - error TS2689: Cannot extend an interface 'http.IncomingMessage'. Did you mean 'implements'?

21     export class IncomingMessage extends http.IncomingMessage {
Run Code Online (Sandbox Code Playgroud)

这是我的package.json文件

{
  "name": "opticare",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "build": "ng build",
    "ng": "ng",
    "start": "ng serve",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^8.2.14",
    "@angular/common": "^8.2.14",
    "@angular/compiler": "^8.2.14",
    "@angular/core": "^8.2.14",
    "@angular/forms": "^8.2.14", …
Run Code Online (Sandbox Code Playgroud)

node.js npm mean-stack angular

7
推荐指数
1
解决办法
2785
查看次数

动态添加行:Angular Reactive-Form

我想在单击 时动态添加行button。我为此使用反应形式。 这就是我要说的

这是我的 html 代码

<table>
    <thead>
        <tr class='tableHeader'>
            <div fxLayout="row" fxLayoutAlign="start center" fxFlex="1 0 auto">
                <td fxFlex="22" class="pr-4">Name</td>
                <td fxFlex="15" class="pr-4">Price</td>
                <td fxFlex="15" class="pr-4">Loan Term</td>
                <td fxFlex="15" class="pr-4">Quantity</td>
                <td fxFlex="15" class="pr-4">Deposit</td>
                <td fxFlex="15" class="pr-4">Total</td>
            </div>
        </tr>
    </thead>
    <tbody>
        <tr [formGroup]="loanProductForm">
            <div fxLayout="row" fxLayoutAlign="start center" fxFlex="1 0 auto">
                <td fxFlex="22">
                    <mat-form-field appearance="outline" fxFlex="100" class="pr-4">
                        <mat-label>Product </mat-label>
                        <mat-select formControlName="productId" required>
                            <mat-option *ngFor="let product of productList" [value]="product.productId">
                                {{product.name}}
                            </mat-option>
                        </mat-select>
                    </mat-form-field>
                </td>
                <td fxFlex="15">
                    <mat-form-field appearance="outline" fxFlex="100" class="pr-4">
                        <mat-label>Price </mat-label> …
Run Code Online (Sandbox Code Playgroud)

javascript angular angular-reactive-forms

5
推荐指数
1
解决办法
4212
查看次数

this.interceptor.intercept 不是函数 Angular 8

我正在尝试jsonwebtokens在我的 Angular 项目中实现,为此我使用了一个HttpInterceptors. 不幸的是,我面临以下错误:

this.interceptor.intercept 不是函数

我已经搜索了其他 Stackoverflow 线程以应用他们的解决方案,但到目前为止我无法使其工作。

这是我的 TokenInterceptorService

import { Injectable } from '@angular/core';
import { HttpInterceptor } from '@angular/common/http';

@Injectable({
  providedIn: 'root'
})
export class TokenInterceptorService implements HttpInterceptor {

  constructor() { }
  intercept(req, next) {
    let tokenizedReq = req.clone({
      setHeaders: {
        Authorization: 'Bearer xx.yy.zz'
      }
    });
    return next.handle(tokenizedReq)
  }
}

Run Code Online (Sandbox Code Playgroud)

这是我的 app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import …
Run Code Online (Sandbox Code Playgroud)

http xmlhttprequest angular

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

使用 javascript 更改 css 类属性值

我想动态更改 css 类的属性之一的值

这是我的场景:

我有许多元素使用一个类,而不是获取所有元素并循环它们并应用样式,我想更改已经应用于它们的类属性之一的值。例如

.prodName {
  max-width: 270px;
  display: block;
}
Run Code Online (Sandbox Code Playgroud)

上面的类被许多元素使用,我想改变该类的属性之一,例如

.prodName {
  max-width: 350px <---
  display: block;
}
Run Code Online (Sandbox Code Playgroud)

javascript中有没有简单的方法可以做到这一点?

在我发布这个问题之前,我已经进行了搜索,但没有找到任何简单有用的东西。预先感谢伸出的援助之手。

html javascript css angular

2
推荐指数
1
解决办法
1366
查看次数

如何知道是否点击了垫子分页器的下一个或上一个按钮

我一直在努力检查是否点击了 mat-paginator的first last nextprevious按钮,搜索了一堆网站,但找不到任何合理的方法。

如何检查单击了哪一个按钮?

这是我的分页信息的样子:

在此处输入图片说明

material-design angular-material angular

1
推荐指数
2
解决办法
4281
查看次数

在 JavaScript 中过滤内部过滤器

我需要过滤包含在另一个对象数组中的对象数组中的一些数据。这是我的数据的示例结构。我需要过滤categories

[
    {
    id: 540,
    name:'Makeup kit'
    slug:'makeup-kit',
    status:'publish',
    categories: [
            {
                id: 42, name:'Fashion',slug:'fashion'
            },
            {
                id: 43, name:'Beauty',slug:'beauty'
            }
        ]
    },
    {
    id: 541,
    name:'Silicon gloves'
    slug:'silicon-gloves',
    status:'publish',
    categories: [
            {
                id: 44, name:'Health',slug:'health'
            }
        ]
    },
    {
    id: 650,
    name:'Julep Mask'
    slug:'julep-mask',
    status:'publish',
    categories: [
            {
                id: 43, name:'Beauty',slug:'beauty'
            }
        ]
    }
]
Run Code Online (Sandbox Code Playgroud)

这是我正在尝试的方式

beautyProducts=temp1.filter(product=>product.categories.filter(cat=>cat.id===43))
Run Code Online (Sandbox Code Playgroud)

但我的解决方案似乎不起作用。

javascript

0
推荐指数
1
解决办法
471
查看次数