Controller is not updating $scope.var when redirect


#1

Hi I’ll try to explain my problem with code of course :smile:

I’ve a temaplte with a form and I need to submit to an angular function with a single numeric data

Here is the template:

 <ion-content class="has-header">
            <form action="#" >
                <div>
                   <input type="text" value="" name="number" ng-model="model.number" />{{model.number}}
                 </div>
                <a ng-click="submitAction(number)" class="button button-assertive" href="#/url-location/">Submit</a>
            </form>
        </div>
 </ion-content> 

And here is the controller:

MyModule.controller('MyController', function($scope) {
    $scope.model = {number: 1}; //the first time this is appearing.
    $scope.submitAction = function(number){
       /**
        * This code below is never updating the template
        */
        $scope.model.number = 2; 
    }
});

I don’t understand how to solve this, I’ve read about the ionic functions treat that as an “isolated scope?” (why inside of a controller function?) how its supposed I’ll update the data “number” after my function process if I can’t update the global $scope.number inside of my controller function?
Also I’ve read about $apply, $digest but nothing works… I hope somebody can help me.