0

I am working on an Angular app using Bootstrap and D3 for most of the visuals. I am using the accordion directive from here. I would like to trigger a change in my D3 chart when accordion groups open and close. How can I hook into this? I'm thinking I need either a way to run callbacks, update the model, or directly query the accordion.

I found this SO question that seems like it might work okay, but since the question is old I'm hoping there is a better way to do this now.

Community
  • 1
  • 1
ben
  • 243
  • 1
  • 12
  • That seems like an okay solution. It's clear what's going on. You can pass that property into your d3 directives and $watch them. – steezeburger May 26 '16 at 04:59

1 Answers1

1

use the simple logic with flag TRUE and FALSE

<!doctype html>
<html ng-app="ui.bootstrap.demo">
<head>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-animate.js"></script>
    <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.3.3.js"></script>
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>

    <div ng-controller="AccordionDemoCtrl">
        <uib-accordion close-others="oneAtATime">
            <uib-accordion-group heading="Accordion-1" ng-click="call(is_open)">
                Accordion-1
            </uib-accordion-group>
            <uib-accordion-group heading="Accordion-2">
                Accordion-2
            </uib-accordion-group>
        </uib-accordion>
    </div>
</body>
</html>

<script type="text/javascript">
    angular.module('ui.bootstrap.demo', ['ngAnimate', 'ui.bootstrap']);
    angular.module('ui.bootstrap.demo').controller('AccordionDemoCtrl', function ($scope) 
    {
        $scope.is_open = false;
        $scope.call = function(status)
        {
            if(status==true)
            {
                $scope.is_open = false;
                console.log("close")
            }
            else
            {
                $scope.is_open = true;
                console.log("open")
            }
        }
    });
</script>
Paresh Gami
  • 4,777
  • 5
  • 23
  • 41