So I have this form submit button in my view 1 -- main.html
<div ng-init="init()" ng-controller="ReadController">
<button type="submit" class="btn btn-primary" ng-click="getFile()">Show File</button>
</div>
Here is my js for modifying the fileContent variable in getFile()
$scope.fileContent = "Hi";
$scope.getFile = function() {
console.log("Chosen file:" + $scope.fileName);
$location.path("/showFile");
$scope.fileContent = "new hi";
};
Here is my routing config
mainApp.config(function($routeProvider) {
$routeProvider.when('/showFile',{
controller:'ReadController',templateUrl:'viewFile.html'});
});
Here is my view 2 -- viewFile.html
<div ng-controller="ReadController" class="container">
{{fileContent}}
</div>
I get the output as "hi" and not "new hi". Does the $scope get reset when navigating to a different page within the same controller?