Answer the question
In order to leave comments, you need to log in
How to pass data from directive to parent scope?
{{event}} Contains json with event data that needs to be passed to the parent scope in $scope.chEvent, but this does not happen, apparently the fancybox directive has its own isolated scope. How to solve the problem?
<div class="eve_cp" ng-repeat="event in events | filterBy:['type']:'main'">
<img ng-src="{{event.image}}" ng-click="openFancybox('#viewEvent')" fancybox event='{{event}}'>
</div>
// Контроллер:
.directive('fancybox', function ($compile, $http) {
return {
scope: true,
restrict: 'EA',
link: function(scope, element, attrs) {
scope.openFancybox = function (href) {
//scope.chEvent.event = angular.fromJson(attrs.event)};
//console.log(scope.chEvent);
var template = angular.element(href);
var compiledTemplate = $compile(template);
compiledTemplate(scope);
$.fancybox.open();
$.fancybox.open({ href: href, type: 'inline' });
};
}
};
})
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