angularjs - 使用 IE8 嵌套 Angular View

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

TLDR:

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

IE8 控制台出现错误:TypeError: 'childNodes' 为 null 或不是 undefined object

看起来很简单,适用于任何 webkit 浏览器,也适用于 IE 9 以上, 但在 IE8 上会中断并显示内部 View 的 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>

最佳答案

你也可以更新你的脚本文件吗..

使用这个

<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"]

关于angularjs - 使用 IE8 嵌套 Angular View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18814132/

相关文章:

angularjs - 首次加载后如何更改angularJS中ng-include的 "src"属性值?

AngularJS 单元测试基础 : testing for a $q deferred object's resolution and rejection in a service

angularjs - ng-repeat 在 div 上不起作用

AngularJS - 选择 ng-repeat 生成的单选按钮时模型未更新

angularjs - ng-repeat 中的 ng-class : conditional class names depending on the item parameters

javascript - 设置 src 之前的 ng-include 渲染

javascript - Angularjs 别名作用域

javascript - Gulp 调试 - 管道到 process.stdout 给出 TypeError ('invalid data' )

javascript - angularjs:如何禁用特定元素的指令

angularjs 指令的 '$element' 是一个注释,因为 ng-if