【问题标题】:Angular2 - No provider for ExceptionHandlerAngular2 - 没有 ExceptionHandler 的提供者
【发布时间】:2016-04-06 10:55:50
【问题描述】:

我正在尝试将 angular2 集成到我的 PHP 应用程序中。 这是我执行的步骤

  1. 包含必要的JS:

../node_modules/angular2/bundles/angular2-polyfills.js ../node_modules/systemjs/dist/system.src.js ../node_modules/typescript/lib/typescript.js ../node_modules/rxjs/bundles/Rx.js ../node_modules/angular2/bundles/angular2.dev.js

  1. 在 Typescript 中创建了 angular2 组件:

import {Component} from 'angular2/core'; @Component({ selector: 'hello-world', template: 'My First Angular 2 App' })
export class AppComponent { }

  1. 配置:

<script> System.config({ transpiler: 'typescript', typescriptOptions: { emitDecoratorMetadata: true } }); </script>

  1. 引导程序:

<script> System.import('angular2/platform/browser').then(function(ng){ System.import('js/app.ts').then(function(src) { ng.bootstrap(src.AppComponent); }).then(null, console.error.bind(console)); }); </script>

输出:

编辑:

好像prototype.js和angular 2有冲突,看pluker:http://plnkr.co/edit/XKKpriTPrTX3tXqqz8v2?p=preview

【问题讨论】:

    标签: javascript ecmascript-6 angular angular2-services


    【解决方案1】:

    我多次收到此错误。据此:Angular Quickstart

    您可能缺少几个脚本:

    <script src="node_modules/es6-shim/es6-shim.min.js"></script>
    <script src="node_modules/systemjs/dist/system-polyfills.js"></script>
    

    如果使用 Internet Explorer,您还应该记住包括:

    <script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
    

    【讨论】:

    • IE 等每个浏览器都有单独的 shim 文件吗?
    • @PardeepJain 我不知道,但您可能可以查看该文件夹中的文件以查看其中的内容:)
    • @PardeepJain:不,没有。可以从该文件内容中找到为 IE11 设置此功能的原因。例如,function.name 确实适用于所有其他主要浏览器,但不适用于 IE。 Here's 更多详情。
    • @RoopeHakulinen 我实际上认为这适用于 >IE8,而不仅仅是 IE11。
    猜你喜欢
    • 2017-01-31
    • 2016-12-18
    • 2016-07-06
    • 1970-01-01
    • 1970-01-01
    • 2017-02-28
    • 2016-12-20
    • 1970-01-01
    • 2016-05-28
    相关资源
    最近更新 更多