In angular.js, I use require: "^helpme",
to inherit a directive's controller in my directive called actionButton
...
angular.module("main.vips").directive("actionButton",
function(LoadbalancerActionButtonService, VipActionButtonService,
NodeActionButtonService, StatusTrackService) {
//get function arguements/services and make them
//accessable for use
var args = Array.prototype.slice.call(arguments);
var services = {};
args.map(function(service) {
//not all services may return objects
if (Object(service) === service) {
services[Object.keys(service)] = service[Object.keys(
service)];
}
});
return {
templateUrl: "vips/directives/action_button.html",
restrict: "AE",
replace: true,
require: "^helpme",
transclude: false,
scope: {
label: "@?",
icon: "@?",
type: "@?",
actions: "=?"
},
link: function(scope, element, attrs) {
return scope.actions = services[attrs.type];
scope.$on('CREATE', function () {
console.log("create");
});
}
}
});
With this template that uses Angular UI Bootstrap dropdown directive:
directives/action_button.html:
<div helpme class="btn-group action-button-icon" dropdown>
....
</div>
How directive is applied:
<div id="{{vip.label}}" action-button type="vip" icon="glyphicon glyphicon-pencil" actions="actions.vips"
class="pull-right"></div>
I get Error: [$compile:ctreq] Controller 'helpme', required by directive 'dropdown', can't be found!
.
This makes no sense because because I am requiring helpme
directive in actionButton
directive.
Is this a bug? Any way I can require other directives in actionButton
directive and still use Angular UI Bootstrap's dropdown
in actionButton
template?