Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

211
Vistas
What is the interface type format in the angular cli?

I was looking at the docs and became lost.

ng generate interface <name> <type>

However it doesn't tell what to put in for type. Like is it just a string, object, array, etc or can I specify properties like email:String username:String age:Number?

about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

ng generate will generate

filename <name>.<type>.ts content:

export interface <name> { //camel case

}

ie

ng generate interface Itest sometype generates file name itest.sometype.ts content

export interface Itest {
}
about 4 years ago · Santiago Trujillo Denunciar

0

Using Angular CLI,

ng g i filename

will create a file by the name filename.ts and will have export interface filename {} in it

about 4 years ago · Santiago Trujillo Denunciar

0

Like so :

interface GraphDatas {
  firstTemperature: Period
  internalTemperature: {
    min: number;
    max: number;
  };
  secondTemperature: Period;
  thresholdAlerts: Threshold;
}

interface Period {
  currentPeriod: number;
  previousPeriod: any;  // TO DO
}

interface Threshold extends Period {
  hasBeenRead: number;
}

You will need to export the interface you want to use in your typescript file after that :

export interface test{
  listComputedDatas: GraphDatas;
}

And in your code :

import {test} from './pathToInterface';

...

randomProperty: test;
// Typescript should detect properties such as 
// randomProperty.listComputedDatas.internalTemperature.min

EDIT : You will be faster creating your own file manually than doing the angular-cli command...

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda