quickmock
quickmock copied to clipboard
Support to define directives with nested controller
Hello, i have a problem using this library, i tell you why... i'm using directives with a nested controller, something like this:
export class AnnouncementsDirective {
constructor() {
let directive = {
restrict: 'E',
template: require('./announcements.html'),
controller: AnnouncementsController,
controllerAs: 'ann',
scope: {},
bindToController: {}
};
return directive;
}
}
and the controller...
class AnnouncementsController {
constructor(
private $scope: ng.IScope,
private $window: ng.IWindowService,
private modalService: ModalService,
private announcementsService: service.announcements.GUIAnnouncementsService,
) { }
and when expose this directive to angular, i do in this way
export default angular.module('proteusGui.announcements', [])
.directive('proteusAnnouncements', () => new AnnouncementsDirective()) .
.name;
so.. this library have not support to this kind of definition, because in this line..
.directive('proteusAnnouncements', () => new AnnouncementsDirective())
i do not pass the injection dependencies because i do this in the controller directly.
you think in any way to use this kind of directives using quickmock? one obvios way is exporting the controller and expose it to angular, something like this:
export class AnnouncementsController {...}
export default angular.module('proteusGui.announcements', [])
.directive('proteusAnnouncements', () => new AnnouncementsDirective())
.controller('AnnouncementsController', AnnouncementsController)
.name;
but i prefer using the nested controller.
thanks in advanced
This is a known issue. Here's the issue that I created a long time ago to address this problem: https://github.com/tennisgent/quickmock/issues/2. Unfortunately I have worked on it a lot and haven't been able to find a good solution to the problem. I've written a lot of code to try to make it work with nested controllers, but nothing has been completely successful. I'll keep working on it, but I don't know if I'll be able to come up with a good solution in the near future. Sorry for the inconvenience.