Using Angular UI-Router with Phonegap

廉价感情. 提交于 2019-11-29 03:56:52

Quick awnser: The problem is the initial slash in your template urls. Remove all initial slashes and you should be good to go.

Example: the excerpt below from your code

templateUrl:'/views/login.header.html'

Should be changed to:

templateUrl:'views/login.header.html'

Explanation: The initial slash makes the path relative to the root. When you are testing on the browser the index.html is probably on http://localhost/index.html, so the request to /views/login.header.html resolves to http://localhost/views/login.headers.html which is ok.

In the other hand, when you are testing on the app generated by phonegap, the index.html is probably on file:///android_asset/www/index.html, so the request resolves to file:///views/login.headers.html wich doesn't exist. If you remove the initial slash from the url the path becomes relative to where you are and the request will resolve to file:///android_asset/www/views/login.headers.html and it should work.

I know the answer was accepted but I want to add another possible cause of the problem: Make sure you are not enabling html5Mode, and not playing with the Prefix on your config(). This was the issue for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!