所以我得到:
错误:$injector:unpr
未知提供者 未知提供者:canOrganiseProvider <-
我不知道为什么,我简单地有这个端点,我已经测试过它工作正常,只是想在我导航到一条路线之前解决这个问题,在尝试解决 canOrganise 时它不起作用,任何想法为什么?
谢谢你。
跳进代码。
终点。
[HttpGet]
[Route("{eventCode}/isOrganiser")]
[Audit(AuditLog.Nothing)]
public IHttpActionResult HasOrganisationalRights([FromUri] string eventCode)
{
var response = Resolve<ICanManageEventOrganisationRightsOperation>().CanOrganiseEvent(new CanManageEventOrganisationRequest
{
EventCode = eventCode,
CurrentUser = CurrentUser,
});
return CreateResponse(response, () => response.CanOrganise );
}
角度路由:
angular.module('Events').config(['$routeProvider',
function ($routeProvider) {
$routeProvider
.when('/event/:event/attendees', {
templateUrl: '/Content/AngularApp/Attendees/List/Template.html',
controller: 'AttendeesController',
resolve: {
'data': ['$route', 'AttendeesService', function ($route, AttendeesService) {
return AttendeesService.getAttendees($route.current.params.event).then(function (response) {
return response.data;
});
}],
'canManage': ['$route', 'AttendeesService', function ($route, AttendeesService) {
return AttendeesService.canManage($route.current.params.event).then(function (response) {
return response;
});
}],
'canOrganise': ['$route', 'AttendeesService', function ($route, AttendeesService) {
return AttendeesService.isOrganiser($route.current.params.event).then(function (response) {
return response;
});
}],
'grouped': ['$route', 'AttendeesService', function ($route, AttendeesService) {
return false;
}]
}
})
}
]);
角服务
angular.module('Events').factory('AttendeesService', ['$http',
function ($http) {
return {
getAttendee: function (eventCode, accountName) {
return $http.get('api/events/' + eventCode + '/attendees/' + accountName + '/');
},
isOrganiser: function (eventCode) {
return $http.get('api/events/' + eventCode + '/isOrganiser');
},
}
角度控制器
angular.module('Events').controller('AttendeesController', ['$scope', '$rootScope', '$routeParams', '$location', '$filter', 'data', 'canManage', 'canOrganise',
'grouped', 'AttendeesService', 'AttendeeAdderService', 'AttendeeDeleterService', 'TrackingService', 'WatcherAdderService', 'WatcherDeleterService',
'GroupColorChangerService', 'DefaultSortingChangerService', 'AdminService',
function ($scope, $rootScope, $routeParams, $location, $filter, data, canManage, canOrganise, grouped, AttendeesService, AttendeeAdderService, AttendeeDeleterService,
TrackingService, WatcherAdderService, WatcherDeleterService, GroupColorChangerService, DefaultSortingChangerService, AdminService) {
...
$scope.isOrganiser = canOrganise;
...
}
]);
angular.module('Events', ['ngRoute', 'ngSanitize', 'angularModalService', 'ngTagsInput' ]);