【问题标题】:Error: [ng:areq] Argument 'Ctrl' is not a function错误:[ng:areq] 参数“Ctrl”不是函数
【发布时间】:2017-04-24 14:58:43
【问题描述】:

我是使用 angularJs 的新手。我正在关注这篇文章asp.net-angularjs 然后我遇到了这样的问题:

entryCtrl.js

(function (app) {
  'use strict';
  app.controller('entryCtrl', entryCtrl);
  entryCtrl.$inject = ['$scope'];
  function entryCtrl($scope) {
    $scope.pageClass = 'page-entry';
  }
})(angular.module('model'));

app.js

(function () {
  'use strict';
  angular.module('model', ['common.core', 'common.ui'])
    .config(config)
    .run(run);

  config.$inject = ['$routeProvider'];
  function config($routeProvider) {
    $routeProvider
        .when("/", {
            templateUrl: "scripts/spa/home/index.html",
            controller: "indexCtrl"
        })
        .when("/entry", {
            templateUrl: "scripts/spa/entry/entry.html",
            controller: "entryCtrl"
        });
  }

然后出现[ng:areq] Argument 'entryCtrl' is not a function, got undefined angular.js:11707之类的错误

但在 indexCtrl.js 中没有错误。 indexCtrl hv 与此相同。我想念什么?

【问题讨论】:

  • 什么是角度版本
  • 就像我在那篇文章中使用的那样。我使用所有捆绑供应商
  • 可能你没有把它们排好
  • @Sajeetharan 我不知道你是什么意思。对不起
  • 请给我一些样品:(

标签: asp.net angularjs asp.net-mvc wcf-rest


【解决方案1】:

您需要将模块声明为

var app = angular.module('model', ['common.core', 'common.ui'])
app.config(config)
app.run(run);

还要确保您已按顺序放置脚本。

【讨论】:

    猜你喜欢
    • 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
    相关资源
    最近更新 更多