Is there a guide to using too many directives with AngularJS?

Is it bad practice, in form or in performance, to use directives for "everything"? I am starting to consider them as functions for rendering HTML and similar functions, they become useful when they are very restrained and combined.

However, I'm starting to worry that this can lead to poor performance or redirection. Here is an example of how I would like to use them - I'm interested in feedback, especially about performance, etc.

  <!-- This could even be wrapped in a my-editing-area-navbar directive -->
  <my-navbard heading="{{pg.constants.navHeader}}">
    <my-jump-to-page></my-jump-to-page>

    <my-divider></my-divider>

    <my-undo></my-undo>
    <my-redo></my-redo>

    <my-divider></my-divider>

    <my-clear></my-clear>

    <my-accept-and-continue acceptFunction="pg.acceptAndContinue()"></my-accept-and-continue>

    <my-divider></my-divider>

    <my-reset-utility></my-reset-utility>
  </my-navbar>

  <my-left-column heading="{{pg.constants.leftColHeading}}">
    <my-preview-component></my-preview-component>

    <my-debug-utility ng-if="{{pg.showDebug}}"></my-debug-utility>
  </my-left-column>

  <my-main-content heading="{{pg.constants.mainHeading}}" subheading="{{pg.constants.mainSubheading}}">
      <my-message-viewer></my-message-viewer>

      <my-content-mainpulator>
        <my-content-frobber></my-content-frobber>

        <my-dohicky></my-dohicky>
      </my-content-mainpulator>
  </my-main-content>
</my-page>
+4
source share
1 answer

-, , , , , . DRY. /, .

, , , - . , .

, html ( , ..), ( , , angular Shadow DOM). , , .

+2

Source: https://habr.com/ru/post/1543930/


All Articles