user2245759
user2245759

Reputation: 467

Failed to load resource error when debugging Cordova app on device

The resource is an html view that should be injected into index.html using Angular's ngInclude.

This works in Ripple, but not when trying to debug on android device (or device emulator).

I am using the VS2013 Cordova project.

The exact error reported in the Visual Studio JavaScript console is:

Failed to load resource
File: test.html, Line: 0, Column: 0

My ngInclude div looks like:

<div ng-include="'/views/test.html'"></div> 

And my test.html is simple:

<div>
  <h3>My template content!</h3>
</div>

Again, this does work in Ripple, just not on device. I'm not sure where to look for any additional details about why this might be failing.

Upvotes: 1

Views: 654

Answers (1)

hgoebl
hgoebl

Reputation: 13007

The way you include the resource works in browser environments where the application is loaded from root context /.

In Android and iOS the resources of the WebView have "longer" URLs.

Changing

<div ng-include="'/views/test.html'"></div> 

into

<div ng-include="'views/test.html'"></div>

should solve the problem.

Upvotes: 3

Related Questions