Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple directives [directive#1, directive#2] asking for isolated scope on

I'm attempting to build a new directive on top of an already existing directive but I am halted in my proces. When loading the page I'm facing the following error:

Multiple directives [directive#1, directive#2] asking for isolated scope on <easymodal title="Test-Title" text="Text-Text" oncancel="show = false" onok="alert();">

The base directive looks like this:

Rohan.directive('easymodal', function () {     return {         restrict: 'E', //      priority: 200,         transclude: true,         replace: true,         scope:{             showModal: "=show",             callback: "=closeFunction",             dismissable: '&'         },         template:             '<div data-ng-show="showModal" class="modal-container">' +                 '<div class="modal-body">' +                     '<div class="title"><span data-translate></span><a data-ng-show="dismissable" data-ng-click="dismiss()">x</a></div>' +                     '<div data-ng-transclude></div>' +                 '</div>' +                 '<div class="modal-backdrop" data-ng-click="dismiss()"></div>' +             '</div>'     }; }); 

And my wrapper directive looks like this:

Rohan.directive('easydialog', function () {     return {         restrict: 'E',         transclude: true,         scope: {title: '@',             text: '@',             onOk: '&',             onCancel: '&'},         replace: true,         template:             '<easymodal>' +                 '{{text}} ' +                 '<hr>' +                 '<button ng-click="{{onCancel}}" value="Cancel"' +                 '<button ng-click="{{onOk}}" value="Ok"' +             '</easymodal>'     }; }); 

My html looks like this:

<easydialog title="Test-Title" text="Text-Text" onCancel="show = false" onOk="alert();" /> 

At first I though my title attribute was conflicting so I removed that attribute in the html line and from my wrapper directive but it was not effective.

like image 209
Rohan Avatar asked Apr 22 '13 13:04

Rohan


People also ask

What are three types of directives?

The three types of directives in Angular are attribute directives, structural directives, and components.

Can we use multiple directives in Angular?

You can not use two structural directives on the same element. You need to wrap your element in another one. It's advised to use ng-container since it wont be rendered in DOM.

What are the two types of directives?

There are four types of directives in Angular, Components directives. Structural directives. Attribute directives.


1 Answers

You need to change your easydialog template and wrap <easymodal> in a <div>.

like image 57
Langdon Avatar answered Oct 21 '22 09:10

Langdon