Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

132
Visualizações
Angular4 error message shows code which differs from the code that's supposed to be serving

I'm writing an app to go into a website, which is intended to calculate simplex algorithms. At the moment I am attempting to create functionality whereby the user can enter the number of coefficients and constraints, name these whatever they wish, and have the app spawn the relevant number and type of UI elements relative to the user's input. Here's what appears to be the relevant portion of the code (app.component.ts):

import { Component } from '@angular/core';

[...]

export class UIComponent {
  id: 1;
  name: string;
  value: number;
  type: string;
}

//* Mock data */
const UICOMPONENTS: UIComponent[] = [
  { id: 1, name: 'coefficient1', value: 4, type: '1dslide' },
  { id: 2, name: 'constraint1', value: 2, type: '2dslide' },
  { id: 3, name: 'min_max', value: 0, type: 'switch' },
  { id: 4, name: 'profit', value: 100, type: 'num_output' }
];

[...]

export class AppComponent {
  title = 'SimutronX';
  uicomponents = UICOMPONENTS;
  [...]
}

This produces an error on screen saying:

Failed to compile.

/root/simutronx/simutron-app/src/app/app.component.ts (18,49): ',' expected.

Which relates to this line:

{ id: 2, name: 'constraint1', value: 2, type: '2dslide' },

Specifically the digit 2 in 2dslide. The error message (it's extremely long so I won't reproduce it all) also includes:

./src/app/app.component.ts
Module parse failed: /root/simutronx/simutron-app/node_modules/@ngtools/webpack/src/index.js!/root/simutronx/simutron-app/src/app/app.component.ts Unexpected token (22:85)
You may need an appropriate loader to handle this file type.
| var UICOMPONENTS = [
|     { id: 1, name: 'coefficient1', value: 4, type: '1dslide' },
|     { id: 2, name: 'constraint1, value: 2, type: ', 2: dslide, ' },: { id: 3, name: 'min_max', value: 0, type: 'switch' }, },
|     { id: 4, name: 'profit', value: 100, type: 'num_output' }
| ];

Which is particularly confusing since, as you can see, that's not how I wrote the code. What's going on here?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You have an error in UIComponent type :

export class UIComponent {
  id: number; //HERE
  name: string;
  value: number;
  type: string;
}

Here a plunker :http://plnkr.co/edit/e6GrylSWznwbYD9VpK2C

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda