I have a component and its HTML file.
component:
hello-world.component.ts
import {Component} from 'angular2/core';
@Component({
selector: 'hello-world',
templateUrl: 'hello-world.html'
})
export class HelloWorld {
yourName: string = '';
}
Template:
hello-world.html:
<label>Name:</label>
<h1>Hello {{yourName}}!</h1>
Now, I have other html template.html
which has no component, for example it contain,
template.html
<h1>Welcome to template file</h1>
<p> This is an example file </p>
Now, I wanted to include template.html
file in the hello-world.html
. How can I do that.
In Angular1 I used to do,
<div ng-include src="'template.html'"></div>
How can I do it in Angular2? I am very new to Angular2.
I searched this question in many places, every one is giving an answer which has components. but didn't get my required solution.
Short: isn't possible yet out of the box.
You could create a Directive
like old ng-include
which will do the work for you..
That Directive
would load the html-file and then paste it to the DOM
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