我试图以角度js显示图像幻灯片。当页面加载时,图像显示正常。我有一个搜索按钮(在页面的起始处将是一个默认字符串)当尝试搜索某些内容时,范围消失。我尝试调试,搜索发出一个http调用,正确返回输出,但绑定有问题。有人可以告诉我这里有什么问题吗?我尝试添加控制台,它使用控制台正确打印但未在ui或幻灯片中显示
<input class="form-control" style="width: 50%;margin: auto;" type="text" placeholder="Location"
no-special-char ng-model="customerLocation"
required>
<button class="btn btn-default" type="submit" ng-click="searchLocation()">Search</button>
<div class="form-group col-md-5">
<carousel interval="myInterval" no-wrap="noWrapSlides">
<slide ng-repeat="slide in slides" active="slide.active">
<a href="{{slide.detailPage}}" target="_blank">
<img ng-src="{{slide.image}}" style="width:300px; height:400px; margin:auto;">
</a>
<div class="carousel-caption" style="color:black">
<p style="background:white">{{slide.text}}</p>
</div>
</slide>
</carousel>
</div>
JS代码:
$http.get('/getCurrentLocation.do').success(
function (result) {
var testing = [];
var index = 1;
for(var i = 0; i < result.length; i++) {
var model = result[i];
var title = {};
title.id = index;
title.text = model.title.title;
title.size = model.count;
title.image = model.titleImageURL;
title.detailPage = model.detailPage;
title.active = (index == 1 ? true : false);
index++;
testing.push(title);
}
$scope.slides = testing; ## works here
});
$scope.searchLocation = function() {
searchForLocation();
}
function searchForLocation() {
if ($scope.customerLocation != null) {
$http.get('/getSearchLocation.do',
{params: {'searchLocation': $scope.customerLocation}}).success(
function (result) {
var testing = [];
var index = 1;
for(var i = 0; i < result.length; i++) {
var model = result[i];
var title = {};
title.id = index;
title.text = model.title.title;
title.size = model.count;
title.image = model.titleImageURL;
title.detailPage = model.detailPage;
title.active = (index == 1 ? true : false);
index++;
testing.push(title);
}
$scope.slides = testing; ## not working here though the testing has values
});
}
}
我认为与角度模型有关但无法弄清楚这里有什么问题