我想使用angularjs進行div排序(拖放)。我做了一個工作正常的演示。但是當我在項目中實現它會給出一個錯誤。ng:areq參數不是函數,在AngularJS中未定義
看下面的代碼。
<div ng-app="reportingModule">
<div class="container-fluid" ng-controller="sortableController" ng-init="chartCollection = @JsonConvert.SerializeObject(chartViewModelCollection)">
<ul id="dashboard" ui-sortable ng-model="chartCollection">
<li ng-repeat="chart in chartCollection" ng-style="setColour(chartCollection.length)">
<div>
...
...
...
</div>
</li>
</ul>
</div>
我有兩個用於維護代碼標準的JS文件。
SortingJS.js
angular.module('reportingModule', ['ui.sortable'])
.controller("sortableController", function ($scope) {
var tmpList = [];
$scope.sortingLog = [];
$scope.sortableOptions = {
stop: function (e, ui) {
// this callback has the changed model
var logEntry = tmpList.map(function (i) {
return i.value;
}).join(', ');
$scope.sortingLog.push('Stop: ' + logEntry);
}
};
})
ReportingMenu.js:
angular.module('reportingModule')
.controller('reportingMenuController', ["$rootScope", "$scope", "chartDetailsService", "reportingFocus", function ($scope, $rootScope, chartDetailsService, reportingFocus) {
...
...
...
])
我[ng:areq] Argument 'reportingMenuController' is not a function, got undefined
錯誤。
當我從sorting.js文件中刪除['ui.sortable']
錯誤消失..但排序也無法正常工作。