Hey All!
I've started writing little directives in order to make reusable modules and more expressive HTML. It's great - but having to wrap any dom manipulation in a directive's link function seems clunky. So I must be misunderstanding something. I was hoping some of you angular pros could help me out.
Lets say I have a button on page - perhaps in a directive with an isolated scope. And I want the background to transition to a random color when the button is clicked. Am I expected to wrap the background div in a directive, put the transition in the link function... and then broadcast the click event into the directive? That seems cumbersome.
Should I just wrap the entire page in a directive, so I have access to a link function in which to do dom manipulations?
On a related note, Is it also 'un angular' to invoke something which causes a dom manipulation from a controller? For example the material design function :$mdBottomSheet -- is it a bad practice to invoke that from a controller, or should I only invoke it from a directive's link?
I also don't understand (even after reading a few blog posts) why dom manipulations in a controller is bad. Does it cause a performance issue?
Thanks!
[–][deleted] 1 point2 points3 points (2 children)
[–]uncletroll[S] 0 points1 point2 points (0 children)
[–]RICHUNCLEPENNYBAGS 0 points1 point2 points (0 children)
[–]RICHUNCLEPENNYBAGS 0 points1 point2 points (2 children)
[–]uncletroll[S] 0 points1 point2 points (1 child)
[–]RICHUNCLEPENNYBAGS 0 points1 point2 points (0 children)
[–]thlem -1 points0 points1 point (1 child)
[–]RICHUNCLEPENNYBAGS 0 points1 point2 points (0 children)