I'm trying to pass some data from a selectbox from one controller to another page with different controller in Angular, but I can't seem to get it working. Could some one help me with this?
This is the selectbox with the DataCtrl:
<div class="searchbox" ng-controller="DataCtrl">
<div class="plumber-by-city col-sm-12 home-text-col">
<select ng-model="selectedItem" ng-change="change()" ng-options="item as item.city for item in items"></select><span class="fa fa-caret-down"></span>
</div>
</div>
On change I am taking the value from the selectbox and placing it into $rootScope:
$scope.change = function() {
$scope.type = $routeParams.type;
console.log($scope.type);
$rootScope = $scope.selectedItem.city;
console.log($rootScope);
};
In the second controller I am trying to get the data from $rootScope and use it there but is not working
app.controller('DataCtrl2', function($rootScope,$scope,$http) {
$scope.selectedItem.city = $rootScope.selectedItem.city;
console.log($rootScope.selectedItem.city);
});