我正在尝试更新 $http 请求中的全局变量,重定向到新页面,然后打印该变量(出错时)。我不确定我是否正确执行此操作,但是当我尝试打印我的变量 ( $rootscope.adHocLevel2
) 时,它仍然为空。在 js 文件中
$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;
});
};
在 Html 我试图打印
<input type="text" ng-model="optLocation" value={{addHocLevel2}} />
提前谢谢