简体   繁体   中英

Angular2(ES5) HashLocationstartergy error

I want to use Hashlocationstartergy for routing in angular2 using ES5. My code snipped for bootstratpping main.js is below:

(function(app) {
    document.addEventListener('DOMContentLoaded', function() {

        ng.platform.browser.bootstrap(app.AppComponent, [
                ng.router.ROUTER_PROVIDERS, ,
                ng.core.provide(ng.common.LocationStrategy, {
                    useClass : ng.common.HashLocationStrategy
                }) ]);
    });

})(window.app || (window.app = {}));

I am getting below error while running it:

uncaught TypeError: Cannot read property 'getOptional' of undefined on application_ref.ts:289

Note: I have added angular2-all.umd.dev.js,Rx.umd.js,shims_for_IE.js,angular2-polyfills.js scripts in html file.

Your problem is located here:

 ng.platform.browser.bootstrap(app.AppComponent, [
    ng.router.ROUTER_PROVIDERS, , <== undefined array item

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM