使用IE8嵌套Angular视图

时间:2013-09-15 15:34:15

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

TLDR:

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

IE8控制台上的

错误:TypeError:'childNodes'为null或不是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>

1 个答案:

答案 0 :(得分: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”]