search

Home  >  Q&A  >  body text

angular.js - In angular, should DOM operations be placed in the controller or the directive?

In Angular, should DOM operations be placed in the controller or the directive?

过去多啦不再A梦过去多啦不再A梦2776 days ago849

reply all(2)I'll reply

  • PHPz

    PHPz2017-05-15 16:52:45

    Put it in the directive.

    The controller must not be able to operate the dom. The controller is the data on the operation page.

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-15 16:52:45

    Directive is required to operate DOM. For relevant angular writing specifications, please refer to:
    https://github.com/johnpapa/angular-styleguide#manipulate-dom-in-a-directive

    reply
    0
  • Cancelreply