Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何修复此条件将始终返回false_Html_Angular_Typescript_Angular Material - Fatal编程技术网

Html 如何修复此条件将始终返回false

Html 如何修复此条件将始终返回false,html,angular,typescript,angular-material,Html,Angular,Typescript,Angular Material,任何人都知道我为什么会遇到这种情况,都会返回“false”,因为在我尝试查看charTypeEnum是否等于ChartType.text时,“typeof ChartType”和“ChartType”类型没有重叠 图表设计 import { ChartType, ChartData, TextData } from 'src/app/mam-chart/models'; export class ChartDesignComponent implements OnInit { chartT

任何人都知道我为什么会遇到这种情况,都会返回“false”,因为在我尝试查看charTypeEnum是否等于ChartType.text时,“typeof ChartType”和“ChartType”类型没有重叠

图表设计

import { ChartType, ChartData, TextData } from 'src/app/mam-chart/models';

export class ChartDesignComponent implements OnInit {
  chartTypeEnum = ChartType;
}

  setupTypes() {
// I got error over here
    if (this.chartTypeEnum == ChartType.text)  { 
      this.cardJsonV2 = JSON.stringify(this.chartData);
    }
}
mam-model.ts

export enum ChartType {
    chart = 1,
    text,
    grid
}
Chart-Design.html

            <mat-form-field appearance="fill">
                <mat-label>Text</mat-label>
                <input matInput [ngModel]="chartData?.textData?.text" />
            </mat-form-field >
使用打字

 if (String(this.chartTypeEnum) === ChartType.text))  { 
使用打字

 if (String(this.chartTypeEnum) === ChartType.text))  { 
尝试将chartTypeEnum=ChartType替换为chartTypeEnum:ChartType

chartTypeEnum=ChartType时,ChartType的类型是否错误?分配给变量chartTypeEnum,而不是定义类型。

尝试将chartTypeEnum=ChartType替换为chartTypeEnum:ChartType


chartTypeEnum=ChartType时,ChartType的类型是否错误?分配给变量chartTypeEnum,而不是定义类型。

您好,谢谢您的回答,但现在我得到的是Stringthis.chartTypeEnum==ChartType.text。。你知道我为什么会得到这个吗?如果你在做检查的话,应该是===谢谢你的回答,但是现在我得到的是if Stringthis.chartTypeEnum==ChartType.text。。你知道我为什么会得到这个吗?如果你在检查的话,应该是