【发布时间】:2017-07-03 22:17:17
【问题描述】:
所以我的代码是这样的
.controller('weinDetailsCtrl', ['$scope', '$stateParams', '$http', '$rootScope',function ($scope, $stateParams, $http, $rootScope) {
$scope.url = "https://winetastic.azurewebsites.net/tables/Wine/" + $rootScope.actWine + "?ZUMO-API-VERSION=2.0.0";
$scope.Winet;
$http({
method: "GET",
url: $scope.url
}).then(function mySucces(response) {
$scope.wineDetails = response.data;
$scope.Winet = $scope.wineDetails.Winetype_ID;
alert($scope.Winet);
}, function myError(response) {
$scope.wineDetails = response.statusText
});
alert($scope.Winet);}])
第一个警报给了我正确的 WineType_ID,第二个警报给了我一个“未定义”。 怎么了?
【问题讨论】:
-
第一个警报将是
undefine,第二个警报将具有价值 -
是的,你是对的,但为什么呢?我想用 winet 做进一步的 sutff,但它总是说它是未定义的
标签: angularjs variables scope undefined