6
I am trying to make ngPanelHead, ngPanelBody and ngPanelFoot directives need to be within the ngPanel directive, otherwise an error is presented on the console. I tried with require however it is not working. I am using version 1.4.8 of Angularjs.
angular
.module('app')
.directive('ngPanel', panel)
.directive('ngPanelHead', panelHead)
.directive('ngPanelBody', panelBody)
.directive('ngPanelFoot', panelFoot);
function panel() {
var directive = {
restrict: 'EA',
replace: true,
transclude: true,
template: '<section class="o-panel" ng-transclude></section>'
}
return directive;
}
function panelHead() {
var directive = {
restrict: 'EA',
// require: '^ngPanel',
replace: true,
transclude: true,
template: '<header class="o-panel__head" ng-transclude></header>'
}
return directive;
}
function panelBody() {
var directive = {
restrict: 'EA',
// require: '^ngPanel',
replace: true,
transclude: true,
template: '<article class="o-panel__body" ng-transclude></article>'
}
return directive;
}
function panelFoot() {
var directive = {
restrict: 'EA',
// require: '^ngPanel',
replace: true,
transclude: true,
template: '<footer class="o-panel__foot" ng-transclude></footer>'
}
return directive;
}
Thank you!
An observation, do not start the name of your
directives
withng
, thedirectives
Angular has this prefix, so you can accidentally create an existing one. Use your own prefix, eg.:bwPanel
– celsomtrindade