Hi Team,
Could you please help me with how to dynamically update the DIV ID within the component.html based on the number of occurences in the page.
<div id="testcontainer1">
</div>
Here the id=testcontainer1 should get dynamically updated as 1,2,3,so on.. based on the number of components being placed on the page.
Thanks!
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Keerthi97 ,
There are couple of things I can suggest here:-
Hi @Keerthi97 ,
There are couple of things I can suggest here:-
Hi,
you can use below for dynamic id
<div id="testcontainer-${resource.path.hashCode}"> </div>
To add number based on occurrence, use Front-end code to append id/data attribute for count.
Hi @arunpatidar ,
Thanks for your response.
Could you please explain how and from where the value of '${resource.path.hashCode} gets appended in html
<div id="testcontainer-${resource.path.hashCode}"> </div>
Thanks.
If I understand your requirement correctly, then please follow below process to implement.
1. Implement a component which can be added to template so that Editors can create pages out of it.
2. Let's assume we have created a page which has component.
3. Develop component logic to read all components added to the page and simpley display that number using sling model.