Failed to load app.html

When I use templateUrlin @Component, I get the following error in the browser console.

@Component({
  selector: 'http-app',
  directives: [
  ],
  templateUrl: "app.html",
})
class HttpApp {
}

Error: not available (in promise): could not load app.html

resolvePromise @ http: // localhost: 8080 / vendor.js: 6504: 33 makeResolver / <@ http: // localhost: 8080 / vendor.js: 6481: 15 ApplicationRef_http: // local: 8080 / common.js: 9943: 26 [616] /http://localhost:8080/vendor.js:6289:21 NgZoneImpl / this.inner <.onInvoke @ http: // localhost: 8080 / common.js: 10351: 33 [616] / http: //localhost:8080/vendor.js:6288:21 [616] /http://localhost:8080/vendor.js:6182:26 scheduleResolveOrReject / <@ http: // localhost: 8080 / vendor.js: 6537: 54 [616] /http://localhost:8080/vendor.js:6322:25 NgZoneImpl / this.inner <.onInvokeTask @ http: // localhost: 8080 / common.js: 10342: 33 [616] / http: //localhost:8080/vendor.js:6321:25 [616] /http://localhost:8080/vendor.js:6222:30 drainMicroTaskQueue @http: // localhost: 8080 / vendor.js: 6440: 27 ZoneTask / this.invoke @ http: // localhost: 8080 / vendor.js: 6392: 23

Project arh .:

Test
-app
--css
--img
--ts
---components
----login
-----login.ts
-----login.html
----services
---app.ts
---app.html
---vendor.ts
--index.html
+4
source share
1 answer

According to your mistake, it seems that the path to your template in the attribute is templateUrlincorrect.

Note that such paths refer to the project root for the styleUrland attributes templateUrl.

I think you could try something like this:

@Component({
  selector: 'http-app',
  directives: [
  ],
  templateUrl: "app/app.html",
})
class HttpApp {
}

See this question for more information:

+1
source

All Articles