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

134
Views
El mensaje de error de Angular4 muestra un código que difiere del código que se supone que debe estar sirviendo

Estoy escribiendo una aplicación para ingresar a un sitio web, que está destinada a calcular algoritmos simplex. En este momento, estoy intentando crear una funcionalidad mediante la cual el usuario pueda ingresar la cantidad de coeficientes y restricciones, nombrarlos como desee y hacer que la aplicación genere la cantidad y el tipo relevantes de elementos de la interfaz de usuario en relación con la entrada del usuario. Esto es lo que parece ser la parte relevante del código ( 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; [...] }

Esto produce un error en la pantalla que dice:

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

Que se relaciona con esta línea:

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

Específicamente el dígito 2 en 2dslide . El mensaje de error (es extremadamente largo, así que no lo reproduciré todo) también incluye:

 ./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' } | ];

Lo cual es particularmente confuso ya que, como puede ver, no es así como escribí el código. ¿Que está pasando aqui?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Tiene un error en el tipo de UIComponent:

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

Aquí un 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!