IE8中的角度视图/路由

时间:2014-02-03 17:15:12

标签: javascript angularjs internet-explorer-8 angular-routing

我遵循了这个文件:http://docs.angularjs.org/guide/ie

但我仍然没有在IE8中看到这些观点。它在现代浏览器中工作正常。 ngRoute帮助模块是否支持IE8?有什么建议吗?

<!DOCTYPE html>
<html xmlns:ng="http://angularjs.org" id="ng-app" ng-app="demoApp">
  <head>
    <!--[if lte IE 8]>
        <script src="//cdnjs.cloudflare.com/ajax/libs/json3/3.3.0/json3.min.js"></script>
        <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
</head>
<body> 
    <div class="container">
        Search by: 
        <span class="searchby"><a href="#/nameSearch">Name</a> | <a href="#/">Back</a></span>
        <div ng-view=""></div>
    </div>
    <script src="angular.min.js"></script>
    <script src="angular-route.min.js"></script>
    <script>
        var demoApp = angular.module("demoApp", ["ngRoute"]);
        demoApp.config(function ($routeProvider) {
            $routeProvider
                .when ('/',
                    {
                        templateUrl: "views/welcomePage.html",
                        controller: "SimpleController"
                    })
                .when ('/nameSearch',
                    {
                        templateUrl: "views/nameSearch.html",
                        controller: "SimpleController"
                    })
                .otherwise ({ redirectTo: '/' });
        })

        demoApp.controller("SimpleController", function ($scope) {
        })          
    </script>   
</body>

2 个答案:

答案 0 :(得分:1)

我弄清楚到底发生了什么。第一个视图没有在IE8和IE9中显示。但意见正在发挥作用。我为ui.router切换了ng-route并将以下内容添加到标题中,现在它可以正常工作。

<meta http-equiv="X-UA-Compatible" content="IE=8">

答案 1 :(得分:0)

是的ngRoute适用于IE8,但设置起来可能很棘手。 我有一个工作的应用程序,我使用如下的东西:

<html xmlns:ng="http://angularjs.org" class="ng-app:demoApp" id="ng-app" ng-app="demoApp">
<head>
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->

    <!--[if lte IE 8]>
        <script src="scripts/json2.js"></script>
    <![endif]-->

     <!--[if lte IE 8]>
      <script>
        document.createElement('ng-include');
        document.createElement('ng-pluralize');
        document.createElement('ng-view');

        // Optionally these for CSS
        document.createElement('ng:include');
        document.createElement('ng:pluralize');
        document.createElement('ng:view');
      </script>
    <![endif]-->
</head>

Json2:https://github.com/douglascrockford/JSON-js/blob/master/json2.js