On the backend, certain HTML elements store their position and size persistently and retrieve them when the page loads. These elements can be dragged and resized by users, with any updates needing to be saved on the backend for consistency across sessions.
In a mode known as "preview," user editing capabilities are disabled, making elements responsive using Angular directives to dynamically calculate size and position. Once preview mode is turned off, attributes revert back to their original state.
Currently, I use ng-style
for preview mode and jquery's .css()
method for non-preview mode to set styles. However, I believe there must be a cleaner approach. How can I achieve two-way binding of CSS so that styles are either populated from or saved to the model depending on the current state?
In summary, I need a method that can both get and set CSS on an HTML element, where only one action is active at any given time based on a condition.