Is there a way to dynamically change the background color of the body based on the hexadecimal value entered in a textfield, without using jQuery? I want the change to happen live as the user types.
The current code works but it doesn't feel right. I prefer not to use jQuery's .css()
method and stick to Angular principles.
<div data-ng-app>
<span data-ng-init="colors.bg='#00FF00';"/>
<style type="text/css">
body {
background: {{colors.bg}}; <!-- Is this the best way to do it? -->
}
</style>
<input type="text" data-ng-model="colors.bg"/>
</div>
If anyone has a cleaner solution for achieving this functionality, I'd appreciate your input. Thanks in advance!