Используя следующую структуру каталогов и код, я изменил использование ocLazyLoad.js в своем ActionController. Но это привело к тому, что у контроллера (ActionController) в коде были голые функции.
Структура каталогов
Хотя желаемый результат достигнут, мне интересно, можно ли внести какие-либо улучшения или исправления.
ActionController.js
function GetActionItems($resource)
{
return $resource('actionitems.json').query().$promise;
}
маршрутный config.js
function config($stateProvider, $urlRouterProvider)
{
$urlRouterProvider
.when('action', 'action')
.when('issue', 'issue')
.when('lesson', 'lesson')
.when('opportunity', 'opporutnity')
.when('risk', 'risk')
.otherwise('main');
$stateProvider
.state('main', {
url: "/main",
//templateUrl: '/app/tool/home/home.html',
controller: 'MainController'
});
$stateProvider
.state('action', {
url: "/actionitems",
templateUrl: '/app/tool/action/ActionItems.html',
controller: 'ActionController'
})
$stateProvider
.state('action.summary', {
url: "/actionitems/all",
templateUrl: '/app/tool/action/ActionItems.html',
controller: 'ActionController'
})
}
app.js
angular.module('Action', ['datatables', 'ngResource']);
var app = angular.module('Main', ['ui.router', 'oc.lazyLoad', 'datatables', 'ngResource', 'Action']);
app.config(['$ocLazyLoadProvider', '$stateProvider', '$urlRouterProvider', function($ocLazyLoadProvider, $stateProvider, $urlRouterProvider){
config($stateProvider, $urlRouterProvider);
$ocLazyLoadProvider.config({
modules: [{
name: 'action',
files: ['app/tool/action/ActionController.js']
}]
});
}]).controller('MainController', function($ocLazyLoad){
}).controller('ActionController', function($ocLazyLoad, $resource, $scope){
$ocLazyLoad.load(['action']).then(
function(){
GetActionItems($resource).then(function(results){
$scope.actionitems = results;
});
});
});
ActionItems.html
<div ng-controller="ActionController">
ActionItems
<table datatables="ng">
<thead>
<tr>
<th>
ID
</th>
<th>
ActionItemTitle
</th>
<th>
Criticality
</th>
<th>
Assignor
</th>
<th>
Owner
</th>
<th>
AltOwner
</th>
<th>
Approver
</th>
<th>
AssignedDate
</th>
<th>
DueDate
</th>
<th>
ECD
</th>
<th>
CompletionDate
</th>
<th>
ClosedDate
</th>
<th>
Team
</th>
<th>
Meeting
</th>
<th>
Phase
</th>
<th>
Source
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="actionitem in actionitems">
<td>{{actionitem.id}}</td>
<td>{{actionitem.title}}</td>
<td>{{actionitem.criticality}}</td>
<td>{{actionitem.assignor}}</td>
<td>{{actionitem.altowner}}</td>
<td>{{actionitem.approver}}</td>
<td>{{actionitem.assigneddate}}</td>
<td>{{actionitem.duedate}}</td>
<td>{{actionitem.ecd}}</td>
<td>{{actionitem.completiondate}}</td>
<td>{{actionitem.closeddate}}</td>
<td>{{actionitem.team}}</td>
<td>{{actionitem.meeting}}</td>
<td>{{actionitem.phase}}</td>
<td>{{actionitem.source}}</td>
</tr>
</tbody>
</table>
</div>