Iteration over enum in ngFor not working in Firefox
I am using angular with typescript to create frontend for my app.
I have created an select element where I create options:
<mat-option
[value]="ift"
*ngFor='let ift of inputFileTypes | elements'>
{{ "generator.inputFileType." + ift | translate}}
</mat-option>
in which I am using pipe to get all elements of my Enum
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({
name: 'elements'
})
export class EnumElementsPipe implements PipeTransform {
transform(data: Object) {
return Object.keys(data);
}
}
inputFileTypes is an enum (in component.ts: inputFileTypes = InputFileType
)
export enum InputFileType {
TYPE1= 'TYPE1',
TYPE2= 'TYPE2'
}
This creates my select with options perfectly well in Chrome and Opera, but does not work on Firefox. No errors, but options are not created. Any idea why?
angular typescript
|
show 1 more comment
I am using angular with typescript to create frontend for my app.
I have created an select element where I create options:
<mat-option
[value]="ift"
*ngFor='let ift of inputFileTypes | elements'>
{{ "generator.inputFileType." + ift | translate}}
</mat-option>
in which I am using pipe to get all elements of my Enum
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({
name: 'elements'
})
export class EnumElementsPipe implements PipeTransform {
transform(data: Object) {
return Object.keys(data);
}
}
inputFileTypes is an enum (in component.ts: inputFileTypes = InputFileType
)
export enum InputFileType {
TYPE1= 'TYPE1',
TYPE2= 'TYPE2'
}
This creates my select with options perfectly well in Chrome and Opera, but does not work on Firefox. No errors, but options are not created. Any idea why?
angular typescript
1
You havereturn = Object.keys(data);
in thetransform
method instead ofreturn Object.keys(data);
. Is it a typo in the question?
– ConnorsFan
Nov 23 '18 at 16:07
Yes, it is typo in the question
– Luk
Nov 23 '18 at 16:10
It works for me in Firefox (see this stackblitz).
– ConnorsFan
Nov 23 '18 at 16:21
It works for me in Firefox. Which version of Angular are you using? Would you mind providing a Minimal, Complete, and Verifiable example? You can use StackBlitz to create one.
– SiddAjmera
Nov 23 '18 at 16:24
Thank you for your help. You have helped me to determinate that the problem was somewhere else.
– Luk
Nov 27 '18 at 7:56
|
show 1 more comment
I am using angular with typescript to create frontend for my app.
I have created an select element where I create options:
<mat-option
[value]="ift"
*ngFor='let ift of inputFileTypes | elements'>
{{ "generator.inputFileType." + ift | translate}}
</mat-option>
in which I am using pipe to get all elements of my Enum
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({
name: 'elements'
})
export class EnumElementsPipe implements PipeTransform {
transform(data: Object) {
return Object.keys(data);
}
}
inputFileTypes is an enum (in component.ts: inputFileTypes = InputFileType
)
export enum InputFileType {
TYPE1= 'TYPE1',
TYPE2= 'TYPE2'
}
This creates my select with options perfectly well in Chrome and Opera, but does not work on Firefox. No errors, but options are not created. Any idea why?
angular typescript
I am using angular with typescript to create frontend for my app.
I have created an select element where I create options:
<mat-option
[value]="ift"
*ngFor='let ift of inputFileTypes | elements'>
{{ "generator.inputFileType." + ift | translate}}
</mat-option>
in which I am using pipe to get all elements of my Enum
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({
name: 'elements'
})
export class EnumElementsPipe implements PipeTransform {
transform(data: Object) {
return Object.keys(data);
}
}
inputFileTypes is an enum (in component.ts: inputFileTypes = InputFileType
)
export enum InputFileType {
TYPE1= 'TYPE1',
TYPE2= 'TYPE2'
}
This creates my select with options perfectly well in Chrome and Opera, but does not work on Firefox. No errors, but options are not created. Any idea why?
angular typescript
angular typescript
edited Nov 23 '18 at 16:15
yurzui
95.7k11189212
95.7k11189212
asked Nov 23 '18 at 16:01
LukLuk
1,5812525
1,5812525
1
You havereturn = Object.keys(data);
in thetransform
method instead ofreturn Object.keys(data);
. Is it a typo in the question?
– ConnorsFan
Nov 23 '18 at 16:07
Yes, it is typo in the question
– Luk
Nov 23 '18 at 16:10
It works for me in Firefox (see this stackblitz).
– ConnorsFan
Nov 23 '18 at 16:21
It works for me in Firefox. Which version of Angular are you using? Would you mind providing a Minimal, Complete, and Verifiable example? You can use StackBlitz to create one.
– SiddAjmera
Nov 23 '18 at 16:24
Thank you for your help. You have helped me to determinate that the problem was somewhere else.
– Luk
Nov 27 '18 at 7:56
|
show 1 more comment
1
You havereturn = Object.keys(data);
in thetransform
method instead ofreturn Object.keys(data);
. Is it a typo in the question?
– ConnorsFan
Nov 23 '18 at 16:07
Yes, it is typo in the question
– Luk
Nov 23 '18 at 16:10
It works for me in Firefox (see this stackblitz).
– ConnorsFan
Nov 23 '18 at 16:21
It works for me in Firefox. Which version of Angular are you using? Would you mind providing a Minimal, Complete, and Verifiable example? You can use StackBlitz to create one.
– SiddAjmera
Nov 23 '18 at 16:24
Thank you for your help. You have helped me to determinate that the problem was somewhere else.
– Luk
Nov 27 '18 at 7:56
1
1
You have
return = Object.keys(data);
in the transform
method instead of return Object.keys(data);
. Is it a typo in the question?– ConnorsFan
Nov 23 '18 at 16:07
You have
return = Object.keys(data);
in the transform
method instead of return Object.keys(data);
. Is it a typo in the question?– ConnorsFan
Nov 23 '18 at 16:07
Yes, it is typo in the question
– Luk
Nov 23 '18 at 16:10
Yes, it is typo in the question
– Luk
Nov 23 '18 at 16:10
It works for me in Firefox (see this stackblitz).
– ConnorsFan
Nov 23 '18 at 16:21
It works for me in Firefox (see this stackblitz).
– ConnorsFan
Nov 23 '18 at 16:21
It works for me in Firefox. Which version of Angular are you using? Would you mind providing a Minimal, Complete, and Verifiable example? You can use StackBlitz to create one.
– SiddAjmera
Nov 23 '18 at 16:24
It works for me in Firefox. Which version of Angular are you using? Would you mind providing a Minimal, Complete, and Verifiable example? You can use StackBlitz to create one.
– SiddAjmera
Nov 23 '18 at 16:24
Thank you for your help. You have helped me to determinate that the problem was somewhere else.
– Luk
Nov 27 '18 at 7:56
Thank you for your help. You have helped me to determinate that the problem was somewhere else.
– Luk
Nov 27 '18 at 7:56
|
show 1 more comment
1 Answer
1
active
oldest
votes
If you are using a version of angular >= 6.1.x, you could simplify this by using the KeyValuePipe
as follows:
<mat-option
[value]="ift"
*ngFor='let ift of inputFileTypes | keyvalue'>
{{ "generator.inputFileType." + ift.key| translate}}
</mat-option>
Which has no issues in firefox, see the following stackblitz
Thank you for your help. You have helped me to determinate that the problem was somewhere else.
– Luk
Nov 27 '18 at 7:56
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53449755%2fiteration-over-enum-in-ngfor-not-working-in-firefox%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you are using a version of angular >= 6.1.x, you could simplify this by using the KeyValuePipe
as follows:
<mat-option
[value]="ift"
*ngFor='let ift of inputFileTypes | keyvalue'>
{{ "generator.inputFileType." + ift.key| translate}}
</mat-option>
Which has no issues in firefox, see the following stackblitz
Thank you for your help. You have helped me to determinate that the problem was somewhere else.
– Luk
Nov 27 '18 at 7:56
add a comment |
If you are using a version of angular >= 6.1.x, you could simplify this by using the KeyValuePipe
as follows:
<mat-option
[value]="ift"
*ngFor='let ift of inputFileTypes | keyvalue'>
{{ "generator.inputFileType." + ift.key| translate}}
</mat-option>
Which has no issues in firefox, see the following stackblitz
Thank you for your help. You have helped me to determinate that the problem was somewhere else.
– Luk
Nov 27 '18 at 7:56
add a comment |
If you are using a version of angular >= 6.1.x, you could simplify this by using the KeyValuePipe
as follows:
<mat-option
[value]="ift"
*ngFor='let ift of inputFileTypes | keyvalue'>
{{ "generator.inputFileType." + ift.key| translate}}
</mat-option>
Which has no issues in firefox, see the following stackblitz
If you are using a version of angular >= 6.1.x, you could simplify this by using the KeyValuePipe
as follows:
<mat-option
[value]="ift"
*ngFor='let ift of inputFileTypes | keyvalue'>
{{ "generator.inputFileType." + ift.key| translate}}
</mat-option>
Which has no issues in firefox, see the following stackblitz
answered Nov 23 '18 at 16:15
Jota.ToledoJota.Toledo
9,52962247
9,52962247
Thank you for your help. You have helped me to determinate that the problem was somewhere else.
– Luk
Nov 27 '18 at 7:56
add a comment |
Thank you for your help. You have helped me to determinate that the problem was somewhere else.
– Luk
Nov 27 '18 at 7:56
Thank you for your help. You have helped me to determinate that the problem was somewhere else.
– Luk
Nov 27 '18 at 7:56
Thank you for your help. You have helped me to determinate that the problem was somewhere else.
– Luk
Nov 27 '18 at 7:56
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53449755%2fiteration-over-enum-in-ngfor-not-working-in-firefox%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You have
return = Object.keys(data);
in thetransform
method instead ofreturn Object.keys(data);
. Is it a typo in the question?– ConnorsFan
Nov 23 '18 at 16:07
Yes, it is typo in the question
– Luk
Nov 23 '18 at 16:10
It works for me in Firefox (see this stackblitz).
– ConnorsFan
Nov 23 '18 at 16:21
It works for me in Firefox. Which version of Angular are you using? Would you mind providing a Minimal, Complete, and Verifiable example? You can use StackBlitz to create one.
– SiddAjmera
Nov 23 '18 at 16:24
Thank you for your help. You have helped me to determinate that the problem was somewhere else.
– Luk
Nov 27 '18 at 7:56