# Popover $scope issue

**URL:** <https://forum.ionicframework.com/t/popover-scope-issue/17835>\
**Category:** ionic-v1\
**Created:** [February 18, 2015, 5:14pm UTC](https://forum.ionicframework.com/t/popover-scope-issue/17835 "2015-02-18T17:14:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![matonu](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@matonu](https://forum.ionicframework.com/u/matonu)\
**Post date:** [February 18, 2015, 5:14pm UTC](https://forum.ionicframework.com/t/popover-scope-issue/17835/1 "2015-02-18T17:14:02Z")

</div>

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](http://codepen.io/matonu/pen/yyKawp)  
Youtube-Video: [http://youtu.be/AV\_lPlHjUY4](http://youtu.be/AV_lPlHjUY4)

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

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![elSolo](https://avatars.discourse-cdn.com/v4/letter/e/76d3ee/32.png) [@elSolo](https://forum.ionicframework.com/u/elSolo)\
**Post date:** [February 18, 2015, 5:54pm UTC](https://forum.ionicframework.com/t/popover-scope-issue/17835/2 "2015-02-18T17:54:49Z")

</div>

Hello,

want to avoid headaches with scopes ?

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

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

> **[Blank Starter](https://codepen.io/elSolo/pen/VYXbpv)**
>
> A starting point for Ionic Demos Forked from \[Ionic\](http://codepen.io/ionic/)'s Pen \[Pull To Refresh: Nightly\](http://codepen.io/ionic/pen/mqolp/). ...

Best regards

---

<div class="post-metadata">

**Author:** ![matonu](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@matonu](https://forum.ionicframework.com/u/matonu)\
**Post date:** [February 18, 2015, 6:16pm UTC](https://forum.ionicframework.com/t/popover-scope-issue/17835/3 "2015-02-18T18:16:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![elSolo](https://avatars.discourse-cdn.com/v4/letter/e/76d3ee/32.png) [@elSolo](https://forum.ionicframework.com/u/elSolo)\
**Post date:** [February 19, 2015, 11:39am UTC](https://forum.ionicframework.com/t/popover-scope-issue/17835/4 "2015-02-19T11:39:13Z")

</div>

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](http://codepen.io/elSolo/pen/RNMxvw).

Best regards.

---

<div class="post-metadata">

**Author:** ![matonu](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@matonu](https://forum.ionicframework.com/u/matonu)\
**Post date:** [February 19, 2015, 12:32pm UTC](https://forum.ionicframework.com/t/popover-scope-issue/17835/5 "2015-02-19T12:32:34Z")

</div>

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