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

281
Vistas
Using html file as template for component in angular 2

I have following app structure

app
   home
       home.html
       home.ts
       home.sass
   app.component.ts
index.html

Essentially I want to divide my pages into separate folders that have style, .ts and .html files related to them

however at the moment loading a template like this

import {Component} from 'angular2/core';

@Component({
    selector: 'admin-app',
    template: 'home/home.html'
})
export class AppComponent { }

literary loads "home/home.html" string as a template where as I want html contents of the home.html file.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

I think that if you want to pass a template, you should use

templateUrl: 'home/home.html'

That should make an http request and load the html into your component.

over 4 years ago · Santiago Trujillo Denunciar

0

You may want to consider using Webpack. In that case, you simply:

@Component({
    selector: 'my-comp',
    template: require('./mycomp.component.html')
})

I've found it to be a solid solution thus far since it will actually throw a compile time error if the URL is incorrect.

over 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