I have a block of html divs.
<div class="my-div-1">
<div class="my-div-2">
<div class="my-div-3">
<p>Hello World</p>
</div>
</div>
</div>
Among this block there is a div with the class my-div-2. How can I remove this, but at the same time, the divs with class my-div-1 and class my-div-2 should remain. It should look like the one shown below.
<div class="my-div-1">
<div class="my-div-3">
<p>Hello World</p>
</div>
</div>
Important: It is necessary to do this in such a way that the reference to the object my-div-1 is not lost.
2
Answers
You can do something like this:
Based on myFlag, you’d have my-div-2 in the html.
How about this.
In the template:
and in component:
You get the most outer element with
Next you get children nodes with:
and you search through the nodes tree with:
If element was found you get the contet of the node and manipulate the DOM with
renderer
service.