簡體   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