angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

Non-string properties in binding expressions not evaluated in IE7

Open jelbourn opened this issue 14 years ago • 5 comments

<!doctype html>
<html>
  <head>    
    <script src="http://code.angularjs.org/angular-1.0.0rc7.min.js"></script>
    <script>
        function Ctrl($scope) {
            $scope.foo = 7;
            $scope.bar = "7";
            $scope.xxx = true;            
        }
    </script>
  </head>  
  <body ng-app id='ng-app' ng-controller='Ctrl'>
    <div>
      number value: {{ foo }}<br />
      string value: {{ bar }}<br />
      bool   value: {{ xxx }}
    </div>
  </body>
</html>

Will output

number value: {{ foo }}
string value: 7
bool value: {{ xxx }} 

Also see this fiddle: http://jsfiddle.net/hmVAa/2/

Anything that is not a string will not evaluate. If the expression is a function call, the result will render if it is a string, otherwise it will still be the literal binding expression.

This is using Internet Explorer 7.0.5730.13 on Windows XP Professional SP3

jelbourn avatar May 01 '12 15:05 jelbourn

Have you tried putting a script tag with Douglas Crockford's json2 library (https://github.com/douglascrockford/JSON-js) before AngularJS? That seems to solve the problem for me, certainly when emulating IE7 mode in IE9.

Tried to get a fiddle working (http://jsfiddle.net/symblify/GYDRz/1/) but it does the same as before - but in the console it complains it cannot change the document mode because it is set explicitly by jsFiddle - so that might explain why.

symblify avatar Jun 27 '12 00:06 symblify

Hello guys, we have the same problem with IE7.. we thought it is related only to the ng-repeat that it is not parsed/compiled correctly but I found this issue later on and tried to apply the json2 library as well but without any success.

We also tried the newest version (1.0.1) and also 1.0.0rc10 which we are currently using in the project.

Can you give us a hint where to look so we can probably quickly patch it or is it more generic problem related to IE7 bugs?

I am also attaching the fiddle where we narrowed the problem: http://jsfiddle.net/rxm4E/11/

lgazo avatar Jul 03 '12 07:07 lgazo

it looks like the interpolation is broken - http://jsfiddle.net/rxm4E/12/ and when placing a form after broken interpolation - http://jsfiddle.net/rxm4E/13/

lgazo avatar Jul 03 '12 07:07 lgazo

including JSON3 for IE7 did fix the issue. I was inspired by https://groups.google.com/forum/?fromgroups#!searchin/angular/IE7/angular/K7Qc_HJ5gUo/9iDWtJvWeckJ & http://jsfiddle.net/ADukg/75/

JSON3 - http://bestiejs.github.com/json3/

lgazo avatar Jul 04 '12 08:07 lgazo

From what I can gather the issue was a missing JSON.stringify() method in IE7. The documentation was updated so I guess that this one can be closed.

pkozlowski-opensource avatar Dec 02 '12 10:12 pkozlowski-opensource