Angular 2, IE9 & pushState issue!

471 views
Skip to first unread message

Andy Macdonald

unread,
Jan 14, 2016, 3:27:33 PM1/14/16
to AngularJS
Hi Guys,

Wondering if any one can help!

I've got Angular 2 working in IE9 eventually but I've now turned on routing and bumped into the next issue - pushState!!

I've added in history.js to polly fill the missing functionality (as can be seen by the console output below)

My index.html head section looks like the following...

<head>
    <title ng-bind="title">xxx</title>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
    <base href="/">

    <link rel="stylesheet" href="/css/bootstrap.min.css" />

    <link rel="stylesheet" href="/css/style.css" />
    <link rel="stylesheet" href="/css/main.css" />


    <script src="/app/reflect.js"></script>
    <script src="https://code.angularjs.org/tools/system.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.1/Rx.js"></script>
    <script src="/app/shims_for_IE.js"></script>

    <script>
        System.config({
        packages: {        
          app: {
            format: 'register',
            defaultExtension: 'js'
          }
        }
      });
      System.import('app/boot')
            .then(null, console.error.bind(console));
    </script>

    <script type="text/ng-template" id="index.html">
        This is my body
    </script>
</head>
<base href="/">

I've tried both hash and url location strategies - both with the same result :(

And console.log for window.history.pushState looks like....
LOG: function(t,n,r,i){r=encodeURI(r).replace(/%25/g,"%");if(o.getHashByUrl(r))throw new Error("History.js does not support states with fragment-identifiers (hashes/anchors).");if(i!==!1&&o.busy())return o.pushQueue({scope:o,callback:o.pushState,args:arguments,queue:i}),!1;o.busy(!0);var s=o.createStateObject(t,n,r),u=o.getHashByState(s),a=o.getState(!1),f=o.getHashByState(a),l=o.getHash(),c=o.expectedStateId==s.id;return o.storeState(s),o.expectedStateId=s.id,o.recycleState(s),o.setTitle(s),u===f?(o.busy(!1),!1):(o.saveState(s),c||o.Adapter.trigger(e,"statechange"),!o.isHashEqual(u,l)&&!o.isHashEqual(u,o.getShortUrl(o.getLocationHref()))&&o.setHash(u,!1),o.busy(!1),!0)}

With the following error being thrown, both before & after using history.js
Potentially unhandled rejection [2] TypeError: Object doesn't support property or method 'pushState'

Any suggestions, help would be gratefully received.. thanks in advance!
Reply all
Reply to author
Forward
0 new messages