$scope does not change on element click

19 views
Skip to first unread message

Nico Nagel

unread,
Mar 20, 2015, 5:09:06 AM3/20/15
to ang...@googlegroups.com
Hi!

In my code I would like to filter my variable $scope.products and change the score value.
I do this on touchstart/click because it's a slider which should filter the results.
Unfortunately it's not working and I can't figure out why :(


Hope someone can give me a hint here...

Sander Elias

unread,
Mar 20, 2015, 8:48:31 AM3/20/15
to ang...@googlegroups.com
Hi Nico,


There where a couple of problems. I solved most of them in the updated fiddle.
You should really read through the john papa's styleguide! it will clarify a lot.

If you are serious about angular, stop trying to solve things the jQuery way.
When you use a click event, it is a native event that is happening, and you need to tell angular to update the view. You didn't, so you did not see the update.
Also, the update was not being done, because the DOM event handler knows nothing about scope, and putting it in the parameters of your function would break all ties.

You seem new to angular, so once again read the above style-guide. Using scope and controllers in the way you did in your sample will end up with difficult to maintain projects.

With kind regards
Sander



Nico Nagel

unread,
Mar 20, 2015, 9:11:49 AM3/20/15
to ang...@googlegroups.com
Thanks for your answer and fiddle!
Yes, I'm new to angular but I really want to learn it the right way.
I will read through the styleguide and try again.

Regards,
Nico
Reply all
Reply to author
Forward
0 new messages