I'm trying to update a global variable within an $http request, redirect to a new page and then print that variable (on error). I'm not sure if i'm doing this correctly, but when I try to print my variable ($rootscope.adHocLevel2
) it remains empty.
In js file
$scope.searchStep2 = function(option) {
$http.post($scope.url, { "option" : option}).
success(function(data, status) {
$scope.status = status;
$scope.data = data;
$rootScope.response = data;
})
.
error(function(data, status) {
$scope.data = data || "Request failed";
$scope.status = status;
$rootScope.response = 'Request failed';
$rootScope.routeAd = {"route": "../adHoc/adhoc.html"};
$rootScope.addHocLevel2 = {"suggestedCategory": "Car","suggestedLocLabel": "world","suggestedShadowURL": "http://www.toyota.com/auris/hybrid"};
$window.location=$rootScope.routeAd.route;
});
};
In Html I'm trying to print
<input type="text" ng-model="optLocation" value={{addHocLevel2}} />
Thanks ahead