Ronald Ronald - 1 year ago 183
Node.js Question

How get a template from a remote URL with AngularJS

I am making an app with NW and AngularJS to make a desktop app, what I want is to get the files from a server(html, css, js).

then I want to do something like the following code:

aux.config(function ($routeProvider) {
.when('/testInformation/', {
templateUrl: 'https://serverName/test.html',
controller: 'shipmentInformationController'
redirectTo: '/'

The problem is that when I run the app it is not getting the html of the template, then I am not sure if this idea is valid on AngularJs or if I need change the logic of that to get the content of the html.

I am getting the error

Error: $sce:insecurl Processing of a Resource from Untrusted Source

Thanks for any help.

Answer Source

I was doing some search on internet and I found a solution that works for me.

The idea is add a domain because by default angularJs only support the same domain, then we can add a white list with the "$sceDelegateProvider" like the folowing code

.config(function ($sceDelegateProvider) {

        // Allow same origin resource loads.
        // Allow loading from our assets domain.  Notice the difference between * and **.

after that when we will set the templateURL, we can use the remote server.

.when('/test1/', {
        templateUrl: '',
        controller: 'test1'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download