search

Home  >  Q&A  >  body text

angular.js - How to add a function (method) in a directive in angularjs to close or hide the html generated by the directive itself

Suppose there is a hello instruction, which generates a form dom in the ctrlA control. There is an icon on the form to close the form. How to add a function or method to the icon to close or hide the form dom?

淡淡烟草味淡淡烟草味2795 days ago678

reply all(1)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-05-15 16:57:56

    Operations on the dom structure are generally performed in instructions, so in the template of the construction instruction, which is the HTML string you construct, directly add functions such as '<form>..<icon ng-click="hideform">...</form>' 这样一旦指令生成表单后我们能够在当前指令的link函数中设置一个scope.hideform=function(){}
    functions to control the hiding and display of the form. Scope and attr are needed here. You can get it in the link parameter

    reply
    0
  • Cancelreply