Reputation: 1342
I'm working on a massive application that uses AngularJs.
When I view the page in IE8 I get super nifty console errors like Object doesn't support property or method 'module'
, Object doesn't support property or method 'widget'
, unable to get value of the property 'controller': object is null or undefined
, and IE really sucks, cant you just tell them to download chrome?
After fighting with it for a while I decided to log the typeof angular
, to which the console returned undefined
.
Everything works as expected in IE9, IE10, and all browsers that don't suck.
Please help!
Edit:
It appears that angular is undefined
before it gets to my first controller, so I don't think it has to do with the ieshim ...
Upvotes: 8
Views: 16152
Reputation: 5
var versionError = angular.module('versionErrors', [])
.controller('versionCtrl', function($scope) {
$scope.name = 'Shantha Moorthy K';
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.min.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8">
<title>AngularJS with Lower version Error's</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div ng-app="versionErrors" ng-controller="versionCtrl">
{{name}}
</div>
</body>
</html>
`If you are using AngularJS + Lower version of IE(8), Please include the content="IE=edge".
After include that you will overcome the below error's.
Upvotes: 0
Reputation: 192
I also had the same issue, my IE9 browser didn't recognize any AngularJs tag, after trying everything I decided to run the html file in a server and it worked.
To summerize, when I executed the file as follows it didn't work
file:///C:/AngularJS/firstTest.html
when I executed the file in the server as follows it did work
http://localhost:7001/AngularJS/firstTest.html
Upvotes: 2
Reputation: 1342
So this was totally my bad (or the guy that started this app months ago).
My application controller had var angular = angular || {}
at the top, IE8 didn't agree with this declaration.
After removing that all is well.
Upvotes: 2
Reputation: 1995
I've been working with IE8 for six months now, feel your pain.
Without seeing your code it's hard exactly to say what's wrong
Here's a very very basic page I just tested with IE8, for you to compare against:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta charset="utf-8">
<title>Prompt Detail View</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- disable browser cache -->
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<!--[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]-->
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/angular-1.0.2.js" ng:autobind></script>
<script>
var pageModule = angular.module('pageModule',[])
.controller('pageCtrl',function($scope) {
$scope.foo = 'my foo';
});
</script>
</head>
<body>
<div ng-app="pageModule"
ng-controller="pageCtrl">
{{foo}}
</div>
</body>
</html>
Upvotes: 5