我试图在已经存在的指令之上构建一个新的指令,但我在我的进程中停止。加载页面时,我面临以下错误:
Multiple directives [directive#1,directive#2] asking for isolated scope on
<easymodal title="Test-Title" text="Text-Text" oncancel="show = false" onok="alert();">
基本指令看起来像这样:
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>' }; });
我的包装指令看起来像这样:
Rohan.directive('easydialog',scope: {title: '@',text: '@',onOk: '&',onCancel: '&'},template: '<easymodal>' + '{{text}} ' + '<hr>' + '<button ng-click="{{onCancel}}" value="Cancel"' + '<button ng-click="{{onOk}}" value="Ok"' + '</easymodal>' }; });
我的html看起来像这样:
<easydialog title="Test-Title" text="Text-Text" onCancel="show = false" onOk="alert();" />
您需要更改您的easydialog模板,并将< easymodal>在< div>中。
原文链接:https://www.f2er.com/angularjs/145269.html