Angular2(ES5)HashLocationstartergy错误

时间:2016-05-18 09:15:21

标签: javascript angular angular2-routing

我想使用Hashlocationstartergy在angular2中使用ES5进行路由。我的代码剪辑为bootstratpping main.js如下:

(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 = {}));

我在运行时遇到错误:

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

注意:我在html文件中添加了angular2-all.umd.dev.js,Rx.umd.js,shims_for_IE.js,angular2-polyfills.js脚本。

1 个答案:

答案 0 :(得分:0)

您的问题位于此处:

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