I am new to angularjs and making a single page application.Please see the attached screen shot I have a dropdown in which there is an apply button and on click of this button I want to call functions that are written in different controller. I have multiple dropdowns on a shell page I am attaching a screen shot of TimeLine dropdown for understanding. There are basically three dropdowns and they are same for every Tab that is why I've placed them in shell page for example there is one dropdown that is populating all clients name from database and have checkboxes so when user select multiple checkboxes and click on Apply button the view under these dropdown should be refreshed with new data.

  1. Complete Picture

// This controller function is used to get data from database and fill the dropdown.

 app.controller("FillDropDownController",function($scope,GetService,$rootScope){

    $rootScope.loading = true;
        // Calling Serivce Method here to get the data and fill dropdown
        $scope.GetDropDownValues = GetService.GetAll("CommonApi", "GetDropDownValues").then(function (d) {
            $scope.GetDropDowns = d;
            $rootScope.loading = false;
        });



// Here goes the function for ng-click = GetSelectedPractices() which gets the selected clients

$scope.GetSelectedPractices = function () { 
        $scope.selectedPractices = []; 
        angular.forEach($rootScope.PracticesList, function (d) { 
            if (d.selected == true) { 
                $scope.selectedClients.push(d.CLIENTNAME); 
            } 
        });  

        $scope.spanValues = $scope.selectedClients; 

    // I am stuck here that how to call controller functions for specific view

    }

    });

Here are two different controller functions(both are updating same view) that are fetching data from database and populate a table or draw a chart based on data. All these controller functions call a generic service to get the data. My problem is that my Apply Button dropdown is placed in shell page becuase if you see image no 2 there are tabs on the page and this "Timeline" dropdown is same for all Tabs(On click of every tab there is a view loaded and its functions called and display table or draw charts on view).

app.controller("GetChargesController", function ($scope, GetService, $rootScope) {
    $scope.Title = "Charges Details List";
    $rootScope.loading = true;
    // Calling Serivce Method here to get the data
    $scope.GetChargesDetails = GetService.GetAll("CommonApi", "GetChargesDetails").then(function (d) {
        $scope.ChargesDetails = d;
        $rootScope.loading = false;
    });


     });

    app.controller("GetPaymentsController", function ($scope, GetService, $rootScope) {
    $scope.Title = "Payments Details List";
    $rootScope.loading = true;
    // Calling Serivce Method here to get the data
    $scope.GetPaymentsDetails = GetService.GetAll("CommonApi", "GetPaymentsDetails").then(function (d) {
        $scope.PaymentsDetails = d;               
        $rootScope.loading = false;
    });


     });
share|improve this question
    
use emit/broadcast events for communication between controllers – Vinod Louis 28 mins ago

You could use the controller as vm technique this (in theory) gives you access to the controller in all the child scopes with the name you give to it here is a post about this technique.

share|improve this answer
    
I recommend you not to make questions this large sometimes the people just past away them xD – german meza 21 mins ago

from you shell page controller, broadcast the event whenever the filter is applied.

  $rootScope.$broadcast('UPDATE-GRAPH');

In your different tabs controller receive the broadcasted event and perform action based on that.

 $rootScope.$on('UPDATE-GRAPH', function() {

       // call update function of your controller from here

      });
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.