2016-01-02 72 views
3

我想在我的PHP应用程序中整合angular2。 下面是已经执行Angular2 - 没有提供ExceptionHandler

  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

  • 创建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>

  • 自举:
  • <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>

    输出: enter image description here

    编辑:

    似乎有与的prototype.js冲突和角2.见pluker:http://plnkr.co/edit/XKKpriTPrTX3tXqqz8v2?p=preview

    回答

    3

    我得到这个错误几次。根据这样的: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> 
    
    +0

    有seprate垫片文件为每像IE浏览器? –

    +1

    @PardeepJain不是我意识到的,但你可以查看该文件夹中的文件,看看有什么:) – Rick

    +0

    @PardeepJain:不,没有。这个为IE11的原因可以从该文件内容中找到。例如,'function.name'在所有其他主流浏览器上都能正常工作,但不能在IE中使用。 [Here's](http://stackoverflow.com/q/6903762)更多详情。 –

    相关问题