Ionic / Angular update scope on page transition

I'm creating an application using the Ionic framework. I have one view with a controller that looks something like this

.controller('MainCtrl', function ($scope, service) { //Controller for app.main

    $scope.main = service.data;
})

A user can go to a sub page from this main page, and further manipulate service.data.

.controller('MainSubCtrl', function ($scope, service) {
    service.data = 'do something';
    $scope.goBack = function ()
    {
        $state.go('app.main');
    }
})

When they are done, $scope.goBack takes them back.

How can I ensure that $scope.main is updated when the view transitions?

You can $watch your change in a function

.controller('MainCtrl', function ($scope, service) { //Controller for app.main
    $scope.$watch(function() {
         return service.data;
    },
    function(newval, oldval) {
         $scope.main = newval;
    }
});