Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get AngularJS routing to work on IE 8

I've got a clean AngularJS 1.2.8 app that I'm just starting. Routing doesn't work on IE 8 but it does work in every other browser (including IE 9). There are no errors in the console. Angular just doesn't fire off the route.

Can someone point me in the right direction? I've already had a look at Angular's IE 8 doc and followed directions to no avail.

The HTML...

<!doctype html>
<html id="ng-app" data-ng-app="app">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta charset="utf-8">
    <title>Learning Content Portal</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width">

    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/main.css">
</head>
<body>
    <div class="container"> 
        <!-- placeholder for views -->
        <div data-ng-view></div>
    </div> <!-- /container --> 

    <script src="js/vendor/jquery-1.10.1.min.js"></script> 
    <script src="js/vendor/json3.min.js"></script> 
    <script src="js/vendor/bootstrap.min.js"></script> 
    <script src="js/vendor/angular/angular.min.js"></script> 
    <script src="js/vendor/angular/angular-route.min.js"></script> 

    <script src="js/app.js"></script> 

</body>
</html>

And the app.js...

var app = angular.module('app', ['ngRoute']);

app.config(function ($routeProvider) {
    $routeProvider
        .when('/searchCourses', {
            templateUrl: 'partials/searchCourses.html',
            controller: 'controller_searchCourses'
        })
        .when('/editCourse', {
            templateUrl: 'partials/editCourse.html',
            controller: 'editCourseController'
        })
        .otherwise({ redirectTo: '/searchCourses' });
});

app.controller('controller_searchCourses', function ($scope) {
    alert('test');
});

There's also a partial but I don't think that matters because it's never firing the alert (or loading the partial).

<div class="container">
    <div>
        Course Count: {{courses.length}}
        <ul>
            <li data-ng-repeat="course in courses | orderBy:course.name">{{ course.name }}</li>
        </ul>
    </div>

    <br />

    <div>
        Name: <input type="text" data-ng-model="newCourse.name" /><br />
        Owner: <input type="text" data-ng-model="newCourse.owner" /><br />
        Code: <input type="text" data-ng-model="newCourse.code" /><br />
        Status: <input type="text" data-ng-model="newCourse.status" /><br />
        <br />
        <button class="btn btn-default" data-ng-click="addCourse()">Add New Course</button>
    </div>
</div>
like image 447
Mark Avatar asked Jan 15 '14 19:01

Mark


1 Answers

You didn't specify namespace in your html

<html xmlns:ng="http://angularjs.org">

and the docs says it is required.

like image 96
Andrew Shustariov Avatar answered Oct 09 '22 14:10

Andrew Shustariov