Our large single page app includes a directive that is utilized in various locations across the page, maintaining its consistent behavior and appearance each time. However, we are experiencing an issue with this directive due to the ng-repeat it contains, resulting in the creation of numerous DOM elements.
We are exploring the possibility of creating a directive that functions as a singleton, meaning it would have only one watch on the collection rather than triggering a new watch every time the directive is implemented. Additionally, we are considering implementing a mechanism to cache the creation of DOM elements to enhance speed. Alternatively, we are open to suggestions for utilizing the same DOM elements multiple times on the same page efficiently.
One idea under consideration involves using a custom ng-repeat that can cache the generated HTML and reuse it when necessary. Is this approach recommended as the most effective solution?