【问题标题】:Angular not working on IE9 possibly due to internal injector?Angular 不能在 IE9 上工作可能是由于内部注入器?
【发布时间】:2015-08-20 11:32:42
【问题描述】:

我有一个 Angular 1.3.15 应用程序,它不能在 Internet Explorer 9 上运行,我收到一个 Unable to get property 'replace' of undefined or null reference 错误,它指向 angular 核心中的这段代码。

抛出的错误是正确执行的,但我不知道这个函数通常做什么以及在 IE9 上缺少什么才能正常工作。

function createInternalInjector(cache, factory) {

    function getService(serviceName, caller) {
      if (cache.hasOwnProperty(serviceName)) {
        if (cache[serviceName] === INSTANTIATING) {
          throw $injectorMinErr('cdep', 'Circular dependency found: {0}',
                    serviceName + ' <- ' + path.join(' <- '));
        }
        return cache[serviceName];
      } else {
        try {
          path.unshift(serviceName);
          cache[serviceName] = INSTANTIATING;
          return cache[serviceName] = factory(serviceName, caller);
        } catch (err) {
          if (cache[serviceName] === INSTANTIATING) {
            delete cache[serviceName];
          }
          throw err;
        } finally {
          path.shift();
        }
      }
    }

作为最后一点,我已经包含了 es5-shim 和 shams,我已经使用了 data-ng-* 属性我已经阅读了多篇关于让 Angular 在 IE9 上工作的文章,但没有一篇描述类似于这个的问题所以我只剩下在SO上问这个问题了。

【问题讨论】:

  • 你能粘贴你最终调用这个的代码吗?
  • @MathewBerg 我的代码没有明确调用它,它是自动运行的,我认为它找不到要注入的服务。

标签: javascript angularjs internet-explorer internet-explorer-9


【解决方案1】:

所以我通过添加断点和调试发现了这个问题,直到我找到它无法注入的服务名称$location,这源于我尝试使用 html5 模式:

$locationProvider.html5Mode(true).hashPrefix('!');

如果我对此发表评论并使用#routes 应用程序的工作原理据我所知,如果有人对如何在 IE9 中使用 html5mode 有想法,我会将您的答案标记为正确的答案,因为我不想要回答我自己的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-10-02
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多