Modal scope not updating (when parent scope does)

Hi folks,

I’ve just noticed this pattern in Ionic.

I’m generating modals with the following snippet:

app.controller "PageCtrl", ()->
    $ionicModal.fromTemplateUrl "templates/modals/item-closeup.html", {
        scope: $scope
        animation: "slide-in-up"
    }
    .then (modal)->
        $scope.itemCloseupModal = modal

When the original $scope updates within PageCtrl the bindings within the modal don’t.

Any idea what I should be doing here? Thanks! :smile:

Here is my Codepen! (Using Beta.5b… even though the title states Beta4)

Sub controller doesn’t propagate changes to parent, and parent doesn’t propagate changes to modal.

Here is a fixed solution : http://codepen.io/calendee/pen/uKJvn

You were not using “dot notation”. So, the model was just copied in place and two-way binding would not occur.

You need to be using objects or arrays instead of simple primitives.

This will explain it all : https://github.com/angular/angular.js/wiki/Understanding-Scopes

1 Like

@Calendee thanks a great ton!

The link is also incredibly useful, would have probably been stuck in this longer. :smile: