ng-include工作在firefox中不能使用chrome

时间:2017-04-06 11:22:29

标签: javascript html css angularjs

我的代码仅在Firefox中运行,不在chrome中运行。

HTML代码

<div ng-controller="myController1">

    Select View:
        <select ng-model="employeeview">
            <option value="1.html">1</option>
            <option value="2.html">2</option>
        </select>

        <div ng-include="employeeview"></div>
    </div>

角色代码

        var app = angular.module('myApp', []);
        app.controller('myController1', function($scope) {
            var employees = [
            {name: "Inderjeet", dateofbirth: new Date("November 23, 1980"), gender: "male", salery: "5000.788"},
            {name: "Ravi Pandey", dateofbirth: new Date("November 13, 1980"), gender: "male", salery: "5000.788"},
            {name: "Dilip", dateofbirth: new Date("November 30, 1991"), gender: "male", salery: "1000.000"},
            {name: "Deepika", dateofbirth: new Date("jan 25, 1980"), gender: "Female", salery: "50040.788"},
            {name: "Pradeep", dateofbirth: new Date("November 21, 1980"), gender: "male", salery: "5560.788"}
            ];
            $scope.employees = employees;
            $scope.employeeview = "1.html";


        });

1.html内容

1.html content i have attached in main file

2.HTML

演示

2 个答案:

答案 0 :(得分:0)

<div data-ng-include="'views/employeeview.html'">

“''” - &gt;你必须这样做

答案 1 :(得分:0)

评估为URL的AngularJS表达式。如果源是字符串常量,请确保将其用单引号e.g. src="'template.html'"包装。

replace  $scope.employeeview = '1.html';

ng-include="employeeview"