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.
An Angular HTML template renders a view, or user interface, in the browser, just like regular HTML, but with a lot more functionality. When you generate an Angular application with the Angular CLI, the app. component. html file is the default template containing placeholder HTML.
A template is a form of HTML that tells Angular how to render the component. Views are typically organized hierarchically, allowing you to modify or show and hide entire UI sections or pages as a unit. The template immediately associated with a component defines that component's host view.
Angular 2 templating system gives us a syntax to express the dynamic part of our HTML. In Angular 2, a component needs to have a view. To define a view, you can define a template inline (using template) or in a separate file (using templateUrl).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With