Igor Branitsky
Igor Branitsky

Reputation: 27

Why Angular2 component don`t render template, but rendering path to template?

I have an Angular version 2 my components is working without errors but now him don`t render template, early it is working

My component

import template from "./edit.html";
import { Subject } from "rxjs";

@Component({
  selector: "adminOffersEdit",
  template,
})

I don't changed code, Angular2 render path to template enter image description here

How i can fix this ?

I try recompiling all components, its`not work

I try add `templateUrl: "./edit.html" and i get result enter image description here

Upvotes: 0

Views: 47

Answers (2)

Goutham Harshith
Goutham Harshith

Reputation: 283

Angular doesn't read all html by default, you have to mention html path inside templateUrl. In your case the code should be..

import { Subject } from "rxjs";

@Component({
  selector: "adminOffersEdit",
  templateUrl: "./edit.html"
})

Now with that angular knows where your html code is, hopefully this should work.

Upvotes: 0

Robby Cornelissen
Robby Cornelissen

Reputation: 97140

Just set the templateUrl directly in your component. There's no need to import it:

import { Subject } from "rxjs";

@Component({
  selector: "adminOffersEdit",
  templateUrl: "./edit.html",
})

Upvotes: 2

Related Questions