我找到了这个(个人)方便的答案,满足我的需求: /sf/answers/469964771/
但由于我使用的是TypeScript ,所以我可以使用Generics来实现类似的功能:
private equals<T>(x: T, y: T) {
if (x === y) {
return true; // if both x and y are null or undefined and exactly the same
} else if (!(x instanceof Object) || !(y instanceof Object)) {
return false; // if they are not strictly equal, they both need to be Objects
} else if (x.constructor !== y.constructor) {
// they must have the exact same prototype chain, the closest we can …
Run Code Online (Sandbox Code Playgroud) 我正在使用从在线构建生成器生成的自定义构建。
然后我按照用Angular 的富文本编辑器组件编写的文档进行操作,但使用自定义构建而不是使用官方编辑器构建之一。
不知何故,我的工具栏及其图像工具栏和表格工具栏等项目没有显示在我的 Angular 项目中。Executingnpm install
提供了工具栏所需的文件,以"image"
在在线构建示例页面上显示完整的项目(包括等)。
我在这里缺少什么才能成功显示使用在线构建生成器定义的工具栏及其项目?
我想保留更改MatTab
直到得到确认。我已经用来MatDialog
确认了。问题是,在单击“是”之前,选项卡已更改。
例如,在收入选项卡中,我单击调整选项卡。在切换到该选项卡之前,我需要先显示弹出窗口。但我在移动到调整选项卡后收到弹出窗口。
组件模板:
<mat-tab-group (click)="tabClick($event)">
<mat-tab *ngFor="let tab of tabs; let index = index" [label]="tab">
<app-spread></app-spread
</mat-tab>
</mat-tab-group>
Run Code Online (Sandbox Code Playgroud)
组件ts(onClick的方法):
tabClick(clickEvent: any) {
if (clickEvent.target.innerText != 'First') {
this.confirm();
}
}
public async confirm() {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxHeight: '200px',
maxWidth: '767px',
width: '360px',
disableClose: true,
data: {
title: 'Confirmation Message',
content:
'There are valid statements that are not Final. Set the statements as Final?'
} …
Run Code Online (Sandbox Code Playgroud) 我们很清楚,有多种方法可以为导入的模块设置config。我们有“ .forRoot()”,“ useValue”,“ useClass”,这些将在导入模块中使用。
例如,我们要使用ng2-currency-mask。直接从文档中的示例用法中,我们可以CurrencyMaskModule
通过在导入模块(在本例中为AppModule)中进行设置来进行配置:
export const CustomCurrencyMaskConfig: CurrencyMaskConfig = {
align: "right",
allowNegative: true,
decimal: ",",
precision: 2,
prefix: "Module$ ",
suffix: "",
thousands: "."
};
@NgModule({
imports: [
...
CurrencyMaskModule
],
declarations: [...],
providers: [
{ provide: CURRENCY_MASK_CONFIG, useValue: CustomCurrencyMaskConfig }
],
bootstrap: [AppComponent]
})
export class AppModule {}
Run Code Online (Sandbox Code Playgroud)
但是,如果要useValue
动态设置config / (例如,“设置”页面),则必须在组件内部进行更改。现在,我使用以下直接在中编写的代码进行了测试AppComponent
:
import { Component, OnInit, Inject } from '@angular/core';
import { CURRENCY_MASK_CONFIG, CurrencyMaskConfig } from 'ng2-currency-mask/src/currency-mask.config';
@Component({
selector: 'app-root', …
Run Code Online (Sandbox Code Playgroud) dependency-injection typescript angular-module angular angular-dependency-injection
如何检查使用Chrome开发者工具打开的模块的js文件是否被延迟加载?
javascript debugging google-chrome google-chrome-devtools angular
angular ×3
typescript ×3
angular-dependency-injection ×1
ckeditor5 ×1
compare ×1
debugging ×1
ecmascript-6 ×1
equality ×1
javascript ×1
mat-tab ×1
optimization ×1