Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2 - No provider for ExceptionHandler

I am trying to integrate angular2 in my PHP app. Here are the steps I have performed

  1. Included necessary 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. Created angular2 component in Typescript:

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

  1. Config:

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

  1. Bootstrap:

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

Output: enter image description here

EDIT:

It seems that there is a conflict with prototype.js and angular 2. See the pluker: http://plnkr.co/edit/XKKpriTPrTX3tXqqz8v2?p=preview

like image 302
Arvind Bhardwaj Avatar asked May 07 '26 02:05

Arvind Bhardwaj


1 Answers

I got this error a couple of times. According to this: Angular Quickstart

You might be missing a couple of scripts:

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

If using Internet Explorer, you should also remember to include:

<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
like image 149
Rick Avatar answered May 08 '26 15:05

Rick