Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-include not work in PhoneGap

I am trying to build my angularjs app into an android app using PhoneGap Build, but got stucked with the issue of the src of ng-include.

The code below tries to render a html of subheader into the view. It works perfectly in chrome browser, however after I convert the code with phonegap, it does not work. I also tried other path like '../templates/subheader.html' and '/templates/subheader.html', none of them work.

<div class="bar bar-subheader bar-stable" ng-include="'templates/subheader.html'">
</div>

Any suggestions?

like image 748
shaosh Avatar asked Mar 16 '26 18:03

shaosh


2 Answers

It is embarrassing to always answer my own question... However I finally figured it out. 1. The path inside the ng-include should not have the "/" on its left most. 2. The key of this issue is not the ng-include. It is because I was trying to fetch a variable stored in the $cookieStore: For some reason I don't know, the data stored in $cookieStore can't persist between page transition. It impact many components in my page. So I have to change the $cookieStore to another local storage service https://github.com/grevory/angular-local-storage.

like image 118
shaosh Avatar answered Mar 19 '26 06:03

shaosh


I had the same problem, that my include was not shown on the device.
But my problem was that I put the template in an folder which's name started with an underscore _.
This is ignored in the build-process. Renaming the folder helped!

like image 25
Witold Avatar answered Mar 19 '26 08:03

Witold