【问题标题】:0x800a139e - JavaScript runtime error: [ng:areq] Argument 'timesheetListCtrl' is not a function, got undefined0x800a139e - JavaScript 运行时错误:[ng:areq] 参数 'timesheetListCtrl' 不是函数,未定义
【发布时间】:2016-01-13 17:54:06
【问题描述】:

我无法让这个简单的 Angular 应用程序工作。我知道我可能在做一些愚蠢的事情。如果有人可以提供帮助,我将不胜感激。当我运行它时,我收到以下错误:

0x800a139e - JavaScript 运行时错误:[ng:areq] 参数 'timesheetListCtrl' 不是函数,未定义

index.html

<!DOCTYPE html>
<html>
<head lang="en">

    <!-- Style sheets -->
    <link href="Content/bootstrap.css" rel="stylesheet" />
</head>

<body ng-app="timesheetManagement">

    <div class="container">
        <div ng-include="'app/HTML/timesheetListView.html'"></div>
    </div>
    <!-- Library Scripts -->
    <script src="scripts/angular.js"></script>
    <script src="Scripts/angular-resource.js"></script>
    <!-- Application Script -->
    <script src="app/app.js"></script>
    <!-- Services -->
    <script src="common/common.services.js"></script>
    <script src="common/timesheetResource.js"></script>
    <!-- Product Controllers -->
    <script src="app/HTML/"></script>
</body>

</html>

timesheetListView.html

<div class="panel panel-primary"
     ng-controller="timesheetListCtrl as vm">
    <div class="panel-heading"
         style="font-size:large">
        Product List
    </div>

app.js

(function () {
    "use strict";

    var timesheetManagement = angular
        .module("timesheetManagement",
                            ["common.services"]);

}());

timesheetListCtrl.js

(function () {
    "use strict";
    angular
        .module("timesheetManagement")
        .controller("timesheetListCtrl",
                     ["timesheetResource",  timesheetListCtrl]);

    function timesheetListCtrl(timesheetResource) {
        var vm = this;

        timesheetResource.query(function (data) {
            vm.timesheets = data
        });

    }
}());

【问题讨论】:

  • 在 index.html 中包含 timesheetListCtrl.js
  • 我差点尴尬!太明显了!!非常感谢

标签: javascript angularjs


【解决方案1】:

所以,你必须在 index.html 中包含 timesheetListCtrl.js

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-18
    • 2015-11-03
    • 2016-10-23
    • 2015-10-10
    • 2016-11-12
    • 2016-03-04
    • 2015-11-18
    相关资源
    最近更新 更多