There is a directive, the essence of which is to hide the element if the user is a restaurant. So, it works only when there is no ng-show in the child block, since it all works with display none, block

 WhenUserDirective.$inject = ['AuthService']; function WhenUserDirective(AuthService) { return { restrict: 'A', link: function (scope, element, attrs) { if (AuthService.isRest()) { element.hide(); } } } } 

How to make sure that the element is not rendered, if the condition is satisfied, now it is just hiding?
And this is not the best solution, because an advanced user can look at the code and put display: block , but somehow I don’t want to write ng-if everywhere

  • what does it mean everywhere? one place in the template is enough - Grundy
  • and if the project is big? and you need to hide functionality in more than just one place - jashka
  • and what exactly is this ? :) Look, actually, your directive is a manual implementation of the same ng-if. - Grundy
  • Well, no, ng-if does not render if the condition is not fulfilled, but it hides, I need to render it - jashka
  • 2
    element has a remove method - it removes an element from the markup - Grundy

0