Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!