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
Post a Comment