I am new to angular. I want to know before the viewDashboard controller viewDashboard , and I'm not sure how I can detect this.
Basicali after clicking on an item from the menu on the left of Template.fn_change_view() changes Template.active_view to the active name of the view, for example. 'dashboard', and it shows / hides some directives of the view- element.
But after that, the code written inside the inactive directive controller no longer executes. Before this happens, I need to execute one function from this inactive controller. Is there any way to do this?
Hopefully I will write this clearly enough if I do not try to explain better.
HTML:
index.html
<body class="template" ng-controller="TemplateController as Template" ng-class="{'on': Template.loged_in}"> <div class="mainFlexCont"> <left-menu class="menuFlexCont menu" ng-class="{'open': Menu.isMenuOpen}"></left-menu> <view-dashboard class="contentFlexCont" ng-if="Template.fn_active_view('dashboard')"></view-dashboard> </div> </body>
left-menu.html loaded with the leftMenu directive
<ul class="leftMenu"> <li> <a class="toggleLeft" ng-click="Menu.isMenuOpen = !Menu.isMenuOpen" href> <i class="fa fa-bars"></i> Toggle Menu </a> </li> <li ng-repeat="item in Menu.obj_items" ng-click="Template.fn_change_view(item.active)" ng-class="{'active' : Template.fn_active_view(item.active)}"> <a href> <i class="fa {{item.icon}}"></i> {{item.label}} </a> </li> </ul>
dashboard.html - loaded by the viewDashboard directive
<div class="row"> <div class="col-xs-12"> <h1>Dashboard</h1> </div> </div> <div class="row"> <div class="col-lg-7"> <chart-yearly class="chart"></chart-yearly> </div> </div>
JS:
chartYearly directive
app.directive('chartYearly', function () { return{ restrict: 'E', templateUrl: 'views/chart-yearly.html', controller: function ($scope) {
javascript angularjs
Lj wadowski
source share