【问题标题】:Angular $templateCache and $stateProvider fix for native ios phonegap/cordova原生 ios phonegap/cordova 的 Angular $templateCache 和 $stateProvider 修复
【发布时间】:2016-02-19 15:28:38
【问题描述】:

Angular $templateCache、$stateProvider 和 ng-include 在 Web 浏览器中运行良好,但在使用 phonegap/cordova 的原生 ios 上,它不会加载模板或进入状态

我已经检查了清单:

  • 删除<base href="/">
  • 确保路径是相对的“template.html” 与“/template.html”
  • 确保 html5Mode 为 false
  • 在 Angular 之前加载 templates.js
  • 确保依赖注入到位

以下是一些在浏览器中有效但在本机 ios 上无效的示例。

$stateProvider.state('start', {
    url: '',
    templateUrl: 'templates/start/start.html'
});

$state.go('start');

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

有什么想法吗?我找不到有效的解决方案。

【问题讨论】:

  • 它应该可以正常工作,要么是你的路径有问题,要么是你的项目设置有问题。也许您的项目文件夹结构的屏幕截图会有所帮助
  • 谢谢,@FranePoljak - 这是一个配置问题。我在下面添加了我的解决方案。
  • 对于 iOS,您可以在 Safari -> Developer -> 选择设备/模拟器(您的应用运行的位置)-> Index.html 中检查错误,希望这有助于您更轻松地调试错误下次

标签: ios angularjs cordova ionic-framework angular-templatecache


【解决方案1】:

我敢肯定,其他人会遇到这个问题。该解决方案与移动构建根目录中的 config.xml 文件有关。这对我有用...

<allow-navigation href="file://*/*"/>
<allow-navigation href="*"/>
<allow-intent href="file://*/*"/>
<allow-intent href="*"/>
<access origin="file://*/*"/>
<access origin="*"/>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-11
    • 2014-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-16
    相关资源
    最近更新 更多