Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use templateUrl from remote server? Angular 2

I have file with this component with remote URL:

@Component({
  templateUrl: '/mobilesiteapp/template/?path=pages/tabs'
})
export class TabsPage {
}

And my compiler gave me:

[13:28:50]  Error reading template file, "/mobilesiteapp/template/?path=pages/tabs": Error: ENOENT: no such file or directory, open 'D:\denwerready\-readyscript
\modules\mobilesiteapp\appsourse\src\pages\mobilesiteapp\template\?path=pages/tabs'

I don't need this check because I need to get templates from url.

How to fix it? Do anybody know?

like image 939
Alexander Zakusilo Avatar asked Feb 13 '26 13:02

Alexander Zakusilo


1 Answers

What is your usecase?

Using remote templates is not possible, you have to have a local copy of the template to have Angular 2 compiler work correctly.

Optionally, you could use ComponentFactoryResolver and inject a template/component dynamically from your controller.

https://blog.thecodecampus.de/angular-2-dynamically-render-components/

like image 173
Alexander Ciesielski Avatar answered Feb 16 '26 02:02

Alexander Ciesielski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!