EXCEPTION:必须定义令牌

时间:2016-01-26 05:23:13

标签: node.js angular

无法解决这个问题,我不确定它为什么要来。

boot.ts

    "use strict";
import {bootstrap} from '../angular2/platform/browser';
import {appComponent} from '../components/app/appComponent';
bootstrap(appComponent);

appComponent.ts

    'use strict'
import {Component} from '../../angular2/core';
@Component({
  selector: 'app',
  templateUrl: 'components/app/app.html'
})
export class appComponent {
    message:string='Hello html'; 
}

并在HTML文件中

<script>
         System.config({
        defaultJSExtensions: true,
        packages: {        
            app: {
                defaultExtension: 'js'
            }  
        }

      });
        System.import('components/boot').then(null, console.error.bind(console));
    </script>

和堆栈跟踪 enter image description here

1 个答案:

答案 0 :(得分:0)

我看到你使用angular2模块的相对路径。也许你可以尝试这样的事情:

'use strict'; // <------------
import {bootstrap} from 'angular2/platform/browser';
import {appComponent} from '../components/app/appComponent';
bootstrap(appComponent);

'use strict';
import {Component} from 'angular2/core'; // <------------
@Component({
  selector: 'app',
  templateUrl: 'components/app/app.html'
})
export class appComponent {
  message:string='Hello html'; 
}

您需要将Angular2 dist这样包含在您的HTML文件中:

<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
(...)

希望它可以帮到你, 亨利