Maddoxswe
Maddoxswe

Reputation: 145

Cordova ios angularjs not finding template

I have a problem when i try to use a cordova ios app i built in xcode. Its starts and then i get a error that angularjs failed to load template. The same app works fine on browser and android.

The steps i do to build it

cordova build ios in terminal.

Then i open the .xcworkspace file to open it in xcode. Then i build it to a connected iphone. I get a splashscreen and i see that my init promisechain runs but then it stops.

templateUrl: 'js/modules/header/html/header.html',

Filestructure is www -> js -> modules -> header -> html -> header.html

The error i get is :

020-05-13 15:59:05.496068+0200 [3439:2658415] ERROR: [$templateRequest:tpload] http://errors.angularjs.org/1.7.8/$templateRequest/tpload?p0=.%2Fjs%2Fmodules%2Fheader%2Fhtml%2Fheader.html&p1=-1&p2= file:///var/containers/Bundle/Application//.app/www/js/node_modules/angular/angular.min.js:7

Anyone have an idea how to solve it ?

Upvotes: 2

Views: 634

Answers (2)

kunj choksi
kunj choksi

Reputation: 391

As iOS requires web view to run the Cordova application. I needed to install the following plugin. Mine issue was resolved after plugin installation and rebuilding the app.

Upvotes: 0

Maddoxswe
Maddoxswe

Reputation: 145

So the problem was CORS.

After installing the plugin https://github.com/oracle/cordova-plugin-wkwebview-file-xhr it works as intended. I think they will solve it in cordova-plugin-wkwebview but for now the xhr plugin is necessary.

Upvotes: 3

Related Questions