Here is the fiddle: http://jsfiddle.net/yFyxL/2/
angular.module("myApp", []) //
.controller('MainController', function($scope) {
$scope.toggle1 = function() {
$scope.$broadcast('event:toggle');
}
$scope.toggle2 = function() {
$scope.$broadcast('event:toggle');
}
}) //
.directive('toggle', function() {
return function(scope, elem, attrs) {
scope.$on('event:toggle', function() {
elem.slideToggle();
});
};
});
So clicking on toggle1 or toggle2 will open both container at the same moment. But I want to toggle them independently. How can I achieve this?