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

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

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 Report

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 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!