'Template is not rendering in Angular2
I want to render html template by giving url in Angular2, But template is not loading. I am using visual studio code editor, Below is my code and structure.
import {Component} from 'angular2/core';
import {LoginComponent} from '../Login/login.component'
@Component({
selector: 'my-app',
// template: '<h1>Yash Employees</h1><login></login>',
templateUrl: './app.html',
directives: [LoginComponent]
})
export class AppComponent { }
template attribute is working, But templateUrl is not.
app.html contains only single line,
<h1>hi</h1>
What I need to change to resolve this?
Solution 1:[1]
Use Urls for your templateUrl properties as below,
@Component({
selector: 'my-app',
templateUrl: './app/component/app/app.html',
directives: [LoginComponent]
})
Update : As per the documentation ./filename
should work but in your case you say that it is not working I wounder.
Solution 2:[2]
I have this issue because i applied guard to that route. After removing that guard it works fine
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | smit agravat |