Angular.js,内部框架和Firefox [英] Angular.js, iframes and Firefox

查看:125
本文介绍了Angular.js,内部框架和Firefox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种感觉,我缺少这个东西很明显,但我不能做的iframe在Firefox与Angular.js路线工作。

I have a feeling I'm missing something obvious with this, but I can't make iframes to work in Firefox with Angular.js routes.

下面是一个示例plunker code

index.html的文件包含 NG-视图哪些负载 main.html中

<div>
Main content here
<iframe src="#/child"></iframe>
</div>

iframe的指向 /子路线,为其设定 $ routeProvider 加载 child.html 模板:

The iframe points to the /child route, for which $routeProvider is configured to load child.html template:

angular.module('testappApp', [])
  .config(function ($routeProvider) {
    $routeProvider
      .when('/', {
        templateUrl: 'views/main.html'
      })
      .when('/child', {
        templateUrl: 'views/child.html'
      })
      .otherwise({
        redirectTo: '/'
      });
  });

这工作在Chrome和Safari,但不是在Firefox和IE 10(我假设早期版本的IE浏览器将不会工作)。我AP preciate任何帮助,谢谢!

This works in Chrome and Safari, but not in Firefox and IE 10 (I assume earlier versions of IE won't work either). I appreciate any help, thanks!

推荐答案

@jpmorin所以,我只是找到了一个解决方法,它是由您的previous建议样的启发。所以,当我从改变的iframe源#/子的index.html /#/子,一切正常!无需多角度包括等我不完全理解为什么原来的路线在FF失败,而是直接指向了自举应用程序文件,然后加入航线的作品。

@jpmorin so, I just found a workaround, which is kind of inspired by your previous suggestion. So, after I changed the iframe source from #/child to index.html/#/child, everything works! No need for multiple includes of angular etc. I don't fully understand why the original route fails in FF, but pointing directly to the file that bootstraps the app and then adding the route works.

这篇关于Angular.js,内部框架和Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆