0

I have this code with custom attribute header :

<div id="foo" class="col-sm-12 col-md-12"
directives="directives"
header="{ name: 'Landing Page' }" style="border-width:5px; border-style:dashed;"></div>

When I execute this code, it will remove the dashed border but not the Landing Page text.

    var myEl = angular.element( document.querySelector( '#foo' ) );
    myEl.removeAttr('style');
    myEl.removeAttr('header');

Why don't the text disappear and how can I remove custom attribute? Please help and thanks in advance.

sg552
  • 1,521
  • 6
  • 32
  • 59
  • It does - see this working fiddle. https://jsfiddle.net/nj62zvad/ Which angularJS version are you using? – mxlse Aug 07 '16 at 19:03
  • Most likely because it is a directive which has been already compiled when you execute this code. [Don't mix Angular with jQuery](http://stackoverflow.com/questions/14994391/thinking-in-angularjs-if-i-have-a-jquery-background). – Estus Flask Aug 07 '16 at 19:03
  • I use angular 1.5.3 – sg552 Aug 07 '16 at 19:09

1 Answers1

0

I would suggest you to use a directive instead because i don't think you can remove an attribute that has not been defined for that specific tag. If you use a directive you may create a custom attribute.

Vikash Kumar
  • 1,712
  • 1
  • 11
  • 17