javascript - Call controller $scope methods from nested directives -


i have following directives:

directive 1

app.directive('tablediv', function () {     return {         templateurl: 'js/directives/table-div/table-div.html',         replace: true,         scope: {             table: '=',         },         controller: function ($scope, $element, $attrs) {          },         link: function postlink(scope, element, attrs) {          }     } }); 

directive 1 template:

    <div data-table-div-row value="row" sizes="table.tbody.sizes" ng-repeat="row in table.tbody.values"> </div> 

directive 2:

app.directive('tabledivrow', function ($rootscope) {     return {         templateurl: 'js/directives/table-div/table-div-row.html',         replace: true,         scope: {value: '=', sizes: '='},         controller: function ($scope, $element, $attrs) {             $scope.showinfo = function () {                 $scope.visible = true;             };              $scope.hideinfo = function () {                 $scope.visible = false;             };              $scope.hastemplate = function() {                 return ($scope.value.template ? true : false);             }          },         link: function postlink(scope, element, attrs) {             scope.$watch(function () {                 return scope.visible;             }, function (value) {                 if (value === true) {                     $(element).find('div.table-row').addclass('open');                     $(element).find('div.table-row.edit').removeclass('hidden');                 } else {                     $(element).find('div.table-row').removeclass('open');                     $(element).find('div.table-row.edit').addclass('hidden');                  }             }, true);         }     } }); 

directive 2 template:

<div> <div class="row-fluid">     <div class="table-row clearfix">         <div class="{{sizes.first}} first">{{value.display.first}}</div>         <div ng-repeat="cell in value.display.cells" class="{{sizes.cells[$index]}}">{{cell}}</div>         <div class="{{sizes.last}} last regular">             <div ng-switch on="value.display.last">                 <div ng-switch-when="%editbutton%">                     <div class="show-info closed" ng-click="showinfo()"></div>                 </div>                 <div ng-switch-default>                     {{value.display.last}}                 </div>             </div>         </div>     </div> </div> <div ng-if="hastemplate()">     <ng-include src="value.template"></ng-include> </div> 

inside second directive template i'm including dynamic template based on controller $scope model. inside template , in directive template want call function controller $scope. there way achieve that?

a child scope created <ng-include src="value.template"></ng-include>, means parent functions should available in template. in other words, shouldnt have , it'll work - see simple example: http://plnkr.co/edit/es2ul09aspsta5fstzjf?p=preview


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -