Angular 2 app base href with Cordova IOS

旧巷老猫 提交于 2019-12-09 16:50:34

问题


I am developing an application using Angular 2 with cordova. I have used the angular cli to build the appplication. I have now ran into some routing issues on startup when it comes to the IOS application. The base href seems to be set wrong. If I set the base href using: <base href="/" target="_blank"> the application doesn't load. If the base href is set when I bootstrap the application using: ...,provide(APP_BASE_HREF, {useValue:'/'}), ... the application will load but I get the following exception:

EXCEPTION: Error: Uncaught (in promise): Error: Cannot match any routes: 'var/containers/Bundle/Application/3C8966ED-7DDD-4309-8C18-10B778C5AE15/test.app/www'

So the application can't function properly since there are critical files that don't get loaded on the start of the application. For android I encountered the same problem but I found the solution, to set the base href in the following question android solution. Have anybody encountered this problem and have a solution?

Edit: I solved the problem by using this: <base href="./" target="_blank">in index html and remove the provide(APP_BASE_HREF, {useValue:'/'}). This way I have to set change the base href depending if I'm deploying the app to android or ios.


回答1:


I set it as

<base href="www">

and all css, js and images file loading are correct.



来源:https://stackoverflow.com/questions/38475460/angular-2-app-base-href-with-cordova-ios

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