【问题标题】:nested Angular views with IE8使用 IE8 嵌套 Angular 视图
【发布时间】:2013-09-15 15:34:14
【问题描述】:

TLDR:

示例:http://plnkr.co/edit/NeUWHh?p=preview

IE8 控制台出错:TypeError: 'childNodes' is null or not an objectundefined

看起来很简单,适用于任何webkit浏览器,也适用于9以上的IE, 但在 IE8 上中断并显示内部视图的 uc 编译形式(带有花括号和字段名称)。

我的确切代码,与示例代码不同:

jobgrid.html:

<div class="jobContainer">  
    <div class="largeBlock">
        <div>
            <div class="access clicks">
                <a href="#/jobs/{{job.id}}"><h5 class="hasLabel" data-ng-bind="job.title"></h5></a>
                <span class="miniLabel" restrict access="admin recruiter"><a href="#/editJob/{{job.id}}">Edit</a></span>

            </div>
        </div>
        <div class="section" data-ng-bind="job.department.name">

        </div>
        <div class="section" data-ng-bind="job.locations[0].name">

        </div>
    </div>
    <div class="smallBlock">

        <div class="access" restrict access="recruiter admin">
            <div class="section enlarged">
                <a href="#/applicants?job={{job.id}}" data-ng-bind="job.job_stats.applicants_count.total"></a>
            </div>
            <div class="section">
                Applicants
            </div>
        </div>

        <div class="access" restrict access="scouter">
            <div class="section enlarged">
                <a href="#/applicants?job={{job.id}}" data-ng-bind="job.job_stats.applicants_count.referred"></a>
            </div>
            <div class="section">
                Applicants
            </div>
        </div>

    </div>
    <div class="smallBlock">
        <div class="access" restrict access="scouter recruiter admin">
            <div class="section enlarged">
                <a href="#/views/{{job.id}}">0</a>
            </div>
            <div class="section">
                Views
            </div>
        </div>
    </div>  
    <div class="smallBlock buttons">
        <!-- only if the company allows public distribution -->
        <div class="access" restrict access="scouter recruiter admin">
            <div class="section">
                <input type="button" class="tiny button" data-ng-click="layout.toggleShareSection(job.id)" value="Share">
            </div>
            <div class="section">
                <input type="button" class="tiny button" data-ng-click="layout.toggleReferSection(job.id)" value="Refer">
            </div>
        </div>  
    </div>
    <div class="largeBlock">
        <!-- only if the company allows public distribution -->
        <div class="section enlarged top" data-ng-bind="job.reward">

        </div>
        <div class="section enlarged date">
            <i class="foundation-star" data-ng-bind="job.modified | date:'d, MMM'"></i>
        </div>
    </div>
</div>
<hr>

dash.html:

<div class="metaContainer" data-ng-controller="dashCtrl" data-ng-cloak>
    <h1>{{model.title}}</h1>
    <div class="topbox">
        <div class="topboxSection">
        </div>
        <div class="topboxSection">
            <div class="topboxSubSectionLarge">
                <a class="small button">Share all jobs</a>
            </div>
            <div class="topboxSubSectionLarge">
                <a class="small button">Copy my job link</a>
            </div>
        </div>
    </div>
    <div class="topbox">
        <div class="topboxSection">
            <div class="topboxSubSectionLarge">
                <select data-ng-model="model.formData.location_id" data-ng-options="id as name for (id, name) in model.locationsList()">
                     <option value=''>Location</option>
                </select>
            </div>
            <div class="topboxSubSectionLarge">
                <div class="wideFieldContainer">
                    <select data-ng-options="id as name for (id, name) in model.departmentsList()" 
                    data-ng-model="model.formData.department_id">
                        <option value=''>Department</option>
                    </select>
                </div>
            </div>
            <div class="topboxSection">
            </div>
        </div>

        <div class="innerContainer">
                <hr>
                <div data-ng-repeat="job in model.myJobs()" data-ng-cloak>
                    <div data-ng-include src="'partials/jobgrid.html'"></div>
                </div>
        </div>
    </div>
</div>

【问题讨论】:

  • 请按照本教程进行操作。 docs.angularjs.org/guide/ie.
  • 已经这样做了,我正在使用 ng-include 指令作为带有 data- 前缀的属性。并且在我的 index.html 中完成所有需要的 polyfil
  • 因为我没有在 plunker 中看到这就是我问的原因。
  • 如果你使用 ng 指令作为属性,带有 data- 前缀并以 IE8 为目标,你应该在戏剧上没有问题,这也是这令人沮丧的部分原因
  • 确保您已定义 document.createElement('ng-view');。您需要像这样预先创建所有指令元素。请尝试一下。

标签: angularjs angularjs-ng-repeat angularjs-ng-include


【解决方案1】:

你能更新你的脚本文件吗..

使用这个

<html xmlns:ng="http://angularjs.org">
    <head>
      <!--[if lte IE 7]>
        <script src="/path/to/json2.js"></script>
      <![endif]-->
    </head>
    <body>
      ...
    </body>
  </html>

IE 8 Fix

如果你使用 $http.delete api 调用替换它 $http["delete"]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-24
    • 1970-01-01
    • 1970-01-01
    • 2016-06-03
    相关资源
    最近更新 更多