angularjs - unable to update controller model value from custom directive with controller as syntax -
i facing problem update model values custom directive using controller syntax. can see through console.log values getting changed in directive not getting updated in controller. <h4>{{self.tabs}} </h4>
shows same values.
in addition want watch on controller (self --> tabs) model add 'active class' when try use watch throwing me out error. have commented part. following watch related code, not working:
$scope.$watch('tabsctrlself.tabs.index', function() { if (tabsctrlself.tabs.index === index) { angular.element($element).addclass('active'); } });
please find plunker, can 1 direct me fix this?
you can use 'ng-class' attribute,eg: <en-tab data-pane="mypanename1" ng-class="{active:index==1}">tab #1</en-tab> <en-tab data-pane="mypanename2" ng-class="{active:index==2}" >tab #2</en-tab> <en-tab data-pane="mypanename3" ng-class="{active:index==3}">tab #3</en-tab> 'index' object in angular: $scope.index, initializes value: $scope.index=1; first item selected default. think object of 'tabsctrl.tabs.index' not angular object, can't auto refresh
Comments
Post a Comment