angular2js: Uncaught Reference Error: System is not defined

前端 未结 6 1429
悲&欢浪女
悲&欢浪女 2020-12-18 21:40

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

6条回答
  •  难免孤独
    2020-12-18 22:19

    Try including the System JS file in your HTML.

    
    

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

    Angular2 way of doing it

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

    index.html

    
        
            AngularJS2 Hello World Demo
    
            
            
            
        
    
        
            
    
        
            
    
    

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

    Hello {{name}}

    ' }) ], angularjs2Component); return angularjs2Component; })(); angular2_1.bootstrap(angularjs2Component);

    Output:

    Hello Harsh


提交回复
热议问题