jquery - How to change css class attribute from ng directive? -


i have css class like

.container{   width:55%; } 

now need write directive change width:82% according condition. directive this.

controls.directive('nimaincontain', function () {                 return {                     require: '^nicontainer',                     restrict: 'e',                     transclude: true,                     replace: false,                     templateurl: 'views/templates/nimaincontain.html',                     compile: function (scope, ielement, iattrs, icontroller) {                         if (scope[0].parentelement.innerhtml.indexof("ni-right-aside") == -1) {                             $(".contaier").css({                                 'width': '82%'                          });                      }                     }                 };             }); 

views/templates/nimaincontain.html template contains ".contaier" class.

when system link directive unable fulfill require. there need change '^' '?' , system works fine....      controls.directive('nimaincontain', function () {                     return {                         require: '?nicontainer',                         restrict: 'e',                         transclude: true,                         replace: false,                         templateurl: 'views/templates/nimaincontain.html',                         link: function (scope, ielement, iattrs, icontroller) {                            if (iattrs.$$element[0].parentelement.innerhtml.indexof("ni-right-aside") == -1) {                                 $(".contaier").css({                                     'width': '82%'                              });                          }                         }                     };                 }); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -