我清除间隔时出现此错误:
ERROR Error: Uncaught (in promise): TypeError: timeout.close is not a function
TypeError: timeout.close is not a function
at exports.clearTimeout.exports.clearInterval (main.js:14)
at LiveTestGraphComponent.ngOnDestroy
Run Code Online (Sandbox Code Playgroud)
设定间隔功能:
this.inrvl = setInterval(() => loop(+new Date()), 5);
Run Code Online (Sandbox Code Playgroud)
和破坏功能:
ngOnDestroy(): void {
if (this.inrvl) clearInterval(this.inrvl)
}
Run Code Online (Sandbox Code Playgroud)
组件在父组件中使用ngIf销毁:
<test *ngIf="data.length" </test>
Run Code Online (Sandbox Code Playgroud) 当函数返回类型为 时Promise<number>,如何通过反射获得它?
如果我只是这样做
Reflect.getMetadata("design:returntype", target, key)
Run Code Online (Sandbox Code Playgroud)
它只是返回Promise,所以有一种方法可以知道这是数字的承诺吗?
name:"Promise"
prototype:Promise {constructor: , then: , catch: , …}
reject:function reject() { … }
resolve:function resolve() { … }
Run Code Online (Sandbox Code Playgroud) 我正在尝试更改边框颜色,但它不起作用。
有我的代码:
<div [style.backgroundColor]="item.color" [style.borderColor]="item.borderColor">
Run Code Online (Sandbox Code Playgroud)
而在 css 中
display: inline-block;
margin: 2px;
border:2px solid ;//red;
height:25px;
width:25px;
border-radius:50%;
-moz-border-radius:50%;
-webkit-border-radius:50%;
Run Code Online (Sandbox Code Playgroud)
backgroundColor 有效,但边框无效。我也在尝试:
[ngStyle]="{border: '2px solid(' + item.borderColor + ')'}"
Run Code Online (Sandbox Code Playgroud)
但是没有效果。
有办法检查属性是否有一些装饰器?
有一种方法可以这样做:
<input type="text" id="name" class="form-control"
[required]='model.decorator["required"]' [minlength]='=model.decorator["minlength"]?.value' maxlength="24"
name="name" [(ngModel)]="hero.name"
#name="ngModel" >
Run Code Online (Sandbox Code Playgroud) 我想创建一个带有初始数据的基类,如下所示:
export abstract class Entity {
constructor(data?) {
if (data) {
Object.assign(this, data);
}
}
}
Run Code Online (Sandbox Code Playgroud)
有一个如下所示的子类:
export class Filter extends Entity{
show = true
constructor(filter?: Partial<Filter>) {
super(filter);
}
}
Run Code Online (Sandbox Code Playgroud)
我面临的问题是,当我创建这样的对象时new Filter({show:false}),我得到以下结果:
Filter {show: true}
Run Code Online (Sandbox Code Playgroud)
基类中的对象没有反映子类中的值。有什么想法为什么会发生这种情况?
我尝试仅在选择时显示选项卡内容:
<mat-tab label="contacts">
<p-contacts [contacts]="selectedPanel.contacts"
*ngIf="tabGroup.selectedIndex === 1">
</p-contacts>
</mat-tab>
Run Code Online (Sandbox Code Playgroud)
这是工作,但我得到了ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ngIf: false'. Current value: 'ngIf: true'.
所以我做错了什么?
我在md-card中有一些输入.有一种方法可以做:
<md-card-content [disabled]="phone._id>
Run Code Online (Sandbox Code Playgroud)
相反,每一个?坦克.
默认情况下,当我将鼠标悬停在一个系列上时,其他系列会变得透明。
我怎样才能禁用这种行为?
这hover: { enabled: false}不起作用。
我有以下前端中间件:
export class FrontendMiddleware implements NestMiddleware {
use(req: any, res: any, next: () => void) {
const url = req.originalUrl;
if (url.indexOf('rest') === 1) {
next();
} else if (allowedExt.filter(ext => url.indexOf(ext) > 0).length > 0) {
res.sendFile(resolvePath(url));
} else {
res.sendFile(resolvePath('index.html'));
}
}
}
Run Code Online (Sandbox Code Playgroud)
它适用于 express,但使用 fastify,res.sendFileis undefined,那么我该如何解决呢?
scrollIntoView当a打开时我打电话MaterialExpansionPanel。
opened(i) {
setTimeout(() =>
this.panels.toArray()[i].nativeElement.scrollIntoView({ behavior: 'smooth' }
));
}
Run Code Online (Sandbox Code Playgroud)
它确实有效,但如果[@.disabled]="true"没有禁用animation(),我必须等到材质动画完成,这看起来很奇怪。
有什么解决办法吗?有没有办法仅在打开时禁用动画?
顺便说一句 - 如何将元素本身发送到“打开”函数?
链接到 stackblitz。
我如何在 glob 中包含所有 ts 文件,但不包含 .d.ts 文件:
glob(path.join(some_path, '**/**.{!d.ts,ts,js}'))
Run Code Online (Sandbox Code Playgroud) 是否可以从基构造函数中获取派生类名称?
class Entity {
constructor() {
// how to log here a class?
console.log('a')
}
}
class a extends Entity {}
new a()
Run Code Online (Sandbox Code Playgroud) 我想为悬停时的所有节点添加背景颜色:
.mat-tree-node {
:hover {
background-color: rgba(255, 220, 0, 0.1) !important;
}
}
Run Code Online (Sandbox Code Playgroud)
尽管“fruit”节点具有“mat-tree-node”类,但它仅适用于叶子
angular ×7
typescript ×5
javascript ×4
css ×1
ecmascript-6 ×1
fastify ×1
highcharts ×1
html ×1
mat-tab ×1
nestjs ×1
node.js ×1