Answer the question
In order to leave comments, you need to log in
How to link two directives?
There are two directives, the first is a menu and the second is a pop-up window, on click on the first one:
<navigation show =' modalShown'></navigation>
<menu-setting show = 'modalShown'></menu-setting>
app.directive('navigation', function(){
return {
restrict: 'E',
scope: {
show: '=',
},
replace: true,
transclude: true,
link: function (scope) {
scope.toggleModal = function(index) {
scope.show = true;
};
},
template:
'<div class="exp">'+
'<div ng-repeat="test in model">'+
'<div class="title" ng-click="toggleModal()">'+
'</div>'+
'</div>'+
'</div>'
};
});
app.directive('menuSetting', function() {
return {
restrict: 'E',
scope: {
show: '='
},
replace: true,
transclude: true,
link: function(scope, element, attrs) {
scope.hideModal = function() {
scope.show = false;
};
},
template:
'<div>'+
'<div class="nmodal" ng-show="show" ng-repeat="test in model">'+
'<div class="modal-overlay" ng-click="hideModal()"></div>'+
'<div class="modal-dialog">'+
'<div class="ng-modal-dialog-content" ng-transclude>'+
'</div>'+
'</div>'+
'</div>'+
'</div>'
};
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question