尝试访问指令中的数据时,AngularJs 崩溃

所以我是 Angular 的新手并试图做一个应用程序。我的服务器非常基础并且是用 go 编写的。这是我的角度代码-


(function() {

    var app = angular.module('dashboard', []);

    app.controller("JobsController", function() {

        this.currentJob = 0;

        this.jobs = jobs;

        this.setCurrentJob = function(index) {

            this.currentJob = index; 

        };      

    });


    var jobs = [

        {

            'id': 1,

            'requester': 'Prakash Sanker',

            'description': 'I want you to give me the entire world'

        },

        {

            'id': 2,

            'requester': 'MJ Watson',

            'description': 'Please give me Spiderman, preferably upside down...but Im not fussy'

        },

        {   'id': 3,

            'requester': 'Josh Lyman',

            'description': 'Matthew Santos as president...or Jed Bartlet..but please not anyone Republican'

        }, 

        {

            'id': 4,

            'requester': 'Barry Allen',

            'description': 'A frictionless suit that wont burst into flames when I run at a zillion miles an hour...its for a friend'

        },

        {

            'id': 5,

            'requeter': 'A. Bambaata',

            'description': 'Boombox, prime condition, from the 80s. Go back in time if you have to'

        }

    ];


})();

这是我的 index.html -


<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>

<script type="text/javascript" src="/dashboard.js"></script>

<body>

    <div class="dashboard">

        <div ng-controller="JobsController as jobsCtrl">

            <div class="jobs">

                {{jobsCtrl.jobs[0]}}

            </div>

        </div>

    </div>

</body>


为什么会这样?


慕码人2483693
浏览 155回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go