angular2js:未捕获的参考错误:系统没有定义 [英] angular2js: Uncaught Reference Error: System is not defined

查看:102
本文介绍了angular2js:未捕获的参考错误:系统没有定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的角度,请帮助。试图运行一个简单的code具有角与角 NG-控制器正在一个javascript定义我在哪里显示HTML中的变量标签,我得到一个错误文件为:

I am new to angular so please help. I am getting an error while trying to run a simple code with angular with angular ng-controller tag where I am displaying a variable in html being defined in a javascript file as:

var MainController = function($scope){
$scope.message = "harsh";

和在这HTML显示: HTML页面

and displaying in html as in this:html page

铬控制台上的错误是:

Uncaught ReferenceError: System is not defined(anonymous function) @ angular2.js:3098

,它指向在angular2js一些功能:

which points to some function in angular2js:

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

我不明白的问题。这是否与我从angularjs.org?

I don't understand the problem. Is it related to the angular2.js which I included from angularjs.org?

推荐答案

尝试,包括在你的HTML体系的JS文件。

Try including the System JS file in your HTML.

<script src="https://jspm.io/system@0.16.js"></script>

勾选此Github上回购任何帮助:<一href=\"https://github.com/kensplanet/angularjs2-hello-world/blob/master/index.html\">https://github.com/kensplanet/angularjs2-hello-world/blob/master/index.html

Check this Github repo for any help: https://github.com/kensplanet/angularjs2-hello-world/blob/master/index.html

做的 Angular2方式

Plunker链接:<一个href=\"http://plnkr.co/edit/36PZLTZ58bXmD4me0cpS?p=$p$pview\">http://plnkr.co/edit/36PZLTZ58bXmD4me0cpS?p=$p$pview

Plunker link: 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>

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

输出:

您好苛刻

这篇关于angular2js:未捕获的参考错误:系统没有定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆