Ilja Ilja - 27 days ago 7
AngularJS Question

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.

Answer

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.

Comments