【发布时间】:2015-06-26 07:02:16
【问题描述】:
我正在尝试使用 angularjs 使 div 可排序(拖放)。我制作了一个运行良好的演示。但是当我在项目中实现时,它给出了一个错误。
看看下面的代码。
<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 文件用于维护代码标准。
排序JS.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'] 时,错误消失了..但排序也不起作用。
【问题讨论】:
标签: jquery angularjs jquery-ui sorting