Popover $scope issue

Hi,

I have a little $scope issue using a popover. I did a popover to set some options and gave it the controller’s $scope.

I have done a codepen as well as a short (30s) video demonstrating the issue.

Codepen: http://codepen.io/matonu/pen/yyKawp
Youtube-Video: http://youtu.be/AV_lPlHjUY4

Hope anyone has an idea of how to make this work…

Thanks a lot.

Hello,

want to avoid headaches with scopes ?

Here’s my medicine: use “Controller as” syntax and voila !

“vm” means “View Model” in this code.

Best regards

Thanks a lot for your quick reply. This is indeed an interesting solution.

However I would like to know why my approach is not working - is it a bug in ionic or am I doing something wrong. As far as I understand it, it should work.

Hello,

I can’t really simply explain with it didn’t work…
I think it’s related to how angular (not ionic) manage scope’s variable sharing and watch propagation (from parent to child or from child to parent).

Another simple solution in your case to avoid these annoying things is to use a “view” variable object with a “mode” property, instead of a “viewMode” variable : the dot syntax “view.mode” seems to fix these kind of strange behaviors.

Please see this codepen.

Best regards.

That’s it. Thanks a lot. I stumbled upon similar issues already - I should have known.