繁体   English   中英

Angular2 - 没有ExceptionHandler的提供者

[英]Angular2 - No provider for ExceptionHandler

我想在我的PHP应用程序中集成angular2。 以下是我执行的步骤

  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

我有几次这个错误。 根据这个: 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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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