我一直在努力运行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) 这是我的 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) 我正在尝试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) 我想动态更改 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中有没有简单的方法可以做到这一点?
在我发布这个问题之前,我已经进行了搜索,但没有找到任何简单有用的东西。预先感谢伸出的援助之手。
我一直在努力检查是否点击了 mat-paginator的first last next或previous按钮,搜索了一堆网站,但找不到任何合理的方法。
如何检查单击了哪一个按钮?
这是我的分页信息的样子:
我需要过滤包含在另一个对象数组中的对象数组中的一些数据。这是我的数据的示例结构。我需要过滤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)
但我的解决方案似乎不起作用。