angular2js:未捕获的参考错误:未定义系统

Har*_*nki 14 javascript angular

我是棱角分明的,所以请帮忙.我试图运行带有角度ng-controller标签的角度的简单代码时出错,我在javascript文件中定义的html中显示一个变量:

var MainController = function($scope){
$scope.message = "harsh";
Run Code Online (Sandbox Code Playgroud)

并在html中显示如下:html页面

chrome控制台上的错误如下:

未捕获的ReferenceError:未定义系统(匿名函数)@ angular2.js:3098

这指向angular2js中的某些功能:

System.register("angular2/src/core/facade/lang", [], true, function(require, exports, module) {
Run Code Online (Sandbox Code Playgroud)

我不明白这个问题.它与angularjs.org中包含的angular2.js有关吗?

ken*_*net 9

尝试在HTML中包含System JS文件.

<script src="https://jspm.io/system@0.16.js"></script>
Run Code Online (Sandbox Code Playgroud)

查看这个Github仓库以获得任何帮助:https://github.com/kensplanet/angularjs2-hello-world/blob/master/index.html

Angular2的做法

Plunker链接:http://plnkr.co/edit/36PZLTZ58bXmD4me0cpS?p =preview

的index.html

<html>
    <head>
        <title>AngularJS2 Hello World Demo</title>

        <script src="https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.87/traceur-runtime.js"></script>
        <script src="https://jspm.io/system@0.16.js"></script>
        <script src="https://code.angularjs.org/2.0.0-alpha.28/angular2.dev.js"></script>
    </head>

    <body>
        <harsh></harsh>

    <script>
        System.import('harsh');
    </script>
        </body>
</html>
Run Code Online (Sandbox Code Playgroud)

harsh.js

var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
    switch (arguments.length) {
        case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);
        case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);
        case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);
    }
};
var angular2_1 = require('angular2/angular2');
var angularjs2Component = (function () {
    function angularjs2Component() {
        this.name = "Harsh";
    }
    angularjs2Component = __decorate([
        angular2_1.Component({
            selector: 'harsh'
        }),
        angular2_1.View({
            template: '<h1>Hello {{name}}<h1>'
        })
    ], angularjs2Component);
    return angularjs2Component;
})();
angular2_1.bootstrap(angularjs2Component);
Run Code Online (Sandbox Code Playgroud)

输出:

你好苛刻