Check existence of attribute in AngularJs Directive

前端 未结 4 390
难免孤独
难免孤独 2021-02-05 00:33

Is is possible to check whether a given attribute is present in a directive, ideally using isolate scope or in a worst case scenario the attributes object.

With a direct

4条回答
  •  隐瞒了意图╮
    2021-02-05 01:27

    The way to do what you want is by looking at the attribute object in the link function:

    link: 
      function(scope, element, attrs) {
        if("status" in attrs)
           //do something
      }
    

提交回复
热议问题