【发布时间】:2023-03-14 17:16:02
【问题描述】:
尝试遵循一些示例,但我得到 app is not defined
app.js
(function () {
"use strict";
var app = angular.module("deviceManagement",['angularUtils.directives.dirPagination']);
}());
所以我希望能够使用或附加到“应用程序”
我有一个控制器 js 文件
(function () {
"use strict";
angular
.module("deviceManagement")
.controller("DeviceListCtrl",
ProductListCtrl);
function ProductListCtrl($http, $scope) {
var vm = this;
vm.devices = [];
deviceList();
function deviceList() {
//..........
}
}
} ());
然后在上面的代码下我这样做
app.filter('deviceStatus', function () {
var deviceStatusLookup = {
1: "New Device",
2: "Activated",
3: "Unactivated"
};
return function (statusId) {
var output = deviceStatusLookup[statusId];
return output;
}
});
页面控制台错误
deviceListCtrl.js:73 Uncaught ReferenceError: app is not defined
【问题讨论】:
-
我认为您应该在 deviceListCtrl.js 中使用 app.controller 代替 angular.controller
标签: javascript angularjs angularjs-directive angularjs-scope