I import enum in .ts file and use it in html file, but get an error which says: "ERROR TypeError: ctx_r3.ParameterType is undefined". How to solve it?

Viewed 13

I have an angular project.

Here's my enum:

export enum ParameterType {
  input = 'input',
  textarea = 'textarea'
}

.ts file:

import { HttpClient, HttpHeaders } from '@angular/common/http';
import { ChangeDetectorRef, Component, HostListener, Input, Output, EventEmitter, OnInit } from '@angular/core';
import { HotKeys } from '../../../models/Enums/hot-keys';
import { ParameterType } from '../../../models/Enums/parameter-type';
import { NodeElement, NodeParameter } from '../../../models/NodeElement';

@Component({
  selector: 'app-node-item',
  templateUrl: './node-item.component.html',
  styleUrls: ['./node-item.component.css']
})
export class NodeItemComponent implements OnInit {
...
}

And my .html file:

<table>
  <tbody>
    <tr *ngIf="getParametersWithoutName().length != 0">
      <td align="center">Type</td>
      <td align="center">Key</td>
      <td align="center">Value</td>
    </tr>
    <tr class="text-alignment" *ngFor="let item of getParametersWithoutName(); index as i;">
      <td>
        <select [(ngModel)]="getParametersWithoutName()[i].optionValue" (focus)="onParameterFocus(i)" (blur)="onParameterBlur()">
          <option value="ParameterType.input">One-line</option>
          <option value="ParameterType.textarea">Multiline</option>
        </select>
      </td>
      <td><input [id]="2*i" [ngModel]="item.name" (ngModelChange)="item.name = $event" (focus)="onParameterFocus(i)" (blur)="onParameterBlur()"/></td>

      <td *ngIf="getParametersWithoutName()[i].optionValue == ParameterType.input"><input [id]="2*i + 1" [ngModel]="item.value" (ngModelChange)="item.value = $event" (focus)="onParameterFocus(i)" (blur)="onParameterBlur()"/></td>
      <td *ngIf="getParametersWithoutName()[i].optionValue == ParameterType.textarea"><textarea rows="2" cols="20" wrap="hard" [id]="2*i + 1" [ngModel]="item.value" (ngModelChange)="item.value = $event" (focus)="onParameterFocus(i)" (blur)="onParameterBlur()"></textarea></td>
    </tr>
  </tbody>
</table>

I thought, if I seted 'export' to enum, imported it in .ts file of my component and used it in .html file of my component, it would work, but it doesn't, cuz, as I see from the error, it doesn't see my enum or.. I dunno. Everytime I get this error: Error

0 Answers
Related