I've encountered a strange issue in my Angular project. I have some components and enums set up, and everything was working fine with one component using the enums. But when I tried to implement the same enums in other components, they are returning "undefined."
The Component where Enums Work:
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import * as moment from 'moment';
import { from } from 'rxjs';
import { WEEKLY_SMART_POINTS } from '../constants';
import { Activity } from '../dom/profile/Activity';
import { Gender } from '../dom/profile/Gender';
import { Goal } from '../dom/profile/Goal';
import { Profile } from '../dom/profile/Profile';
import { ProfileService } from '../services/profile.service';
@Component({
selector: 'app-profile',
templateUrl: './profile.page.html',
styleUrls: ['./profile.page.scss'],
})
export class ProfilePage implements OnInit {
eGender = Gender;
eActivity = Activity;
...
Components where Enums Return Undefined:
import { Component, OnInit } from '@angular/core';
import { Portion } from '../dom/products/Portion';
import { Product } from '../dom/products/Product';
import { Nutrition } from '../dom/products/Nutrition';
import { Gender } from '../dom/profile/Gender';
@Component({
selector: 'app-calculator',
templateUrl: './calculator.page.html',
styleUrls: ['./calculator.page.scss'],
})
export class CalculatorPage implements OnInit {
smartPoints: number | string = '-';
...
/* eslint-disable no-underscore-dangle */
import { Component, OnInit } from '@angular/core';
...
<p><strong>Some Enums:</strong></p>
<pre><code>export enum Gender {
m = 'Man',
f = 'Vrouw',
}
export enum SubSize {
none = '--',
oneEight = '1/8',
oneFourth = '1/4',
oneThird = '1/3',
threeEight = '3/8',
half = '1/2',
fiveEight = '5/8',
twoThird = '2/3',
threeForth = '3/4',
sevenEight = '7/8',
}
I seem to be at a dead-end with this problem. Any help would be greatly appreciated.