0
내 웹 사이트에 작은 각도 모듈을 만들어 데이터베이스에서 클럽 목록을 호출하고보기를 통해 표시해야합니다. 컨트롤러가 자체적으로 업데이트하지 않는데 문제가 있습니다. 컨트롤러 변수가 올바른 데이터를 표시하지만보기를 업데이트하지 않습니다. 여기 내 코드입니다 :각형 컨트롤러가 내보기를 업데이트하지 않습니다
보기 파일 :
<div ng-app="clubFilter" ng-cloak class="col-lg-12" ng-controller="clubController">
{{clubObj.clubs}}
<div class="col-lg-3" id="clubs-filter-left">
<form ng-submit="filterClubs()">
<input type="text" name="location" ng-model="searchTerm" placeholder="Search..." />
<input type="submit" name="submit" value="Submit" />
</form>
<div id="searchInfo" ng-show="(searchTerm != '') || (activityText != '')">
<span ng-show="searchTerm != ''"><strong>Location:</strong> {{searchTerm}}</span>
<span ng-show="activityText != ''"><strong>Activity:</strong> {{activityText}}</span>
<span class=''>(Distance indicated in miles)</span>
</div>
<div id="activityInfo" ng-show="activityText != ''">
<p>Your nearest Leisure Centres with {{activityText}} facilties</p>
</div>
</div>
<div class="col-lg-9" >
<ul class="leisure-centres">
<li ng-repeat="club in clubs" ng-show="club.show">
<div class="centre">
<a class="link" ng-href="http://isca01.bigwavemedia.info{{club.link}}">More info</a>
<a class="link" ng-show="club.distance > 0" ng-href="{club.link}" ng-cloak>{{club.distance}}m</a>
<div class="image" ng-show="club.image > 0">
<img src="{{image}}" alt="{{club.title}}" />
</div>
<div class="details">
<div class="title">
<h3>{{club.title}}</h3>
</div>
<div class="address">
{{club.building}},
{{club.street}},
{{club.city}},
{{club.county}},
{{club.postcode}}
</div>
<div class="tel">
<strong>Tel: </strong>
<a href="tel:{{club.telephone}}" ng-bind="club.telephone"></a>
</div>
<div class="email">
<strong>Email: </strong>
<a href="mailto:{{club.email}}" ng-bind="club.email"></a>
</div>
</div>
</div>
</li>
</ul>
</div>
컨트롤러 :
여기angular.module('clubFilter.controllers', []).
controller('clubController', function($scope, $http, googleMapService, clubService) {
if(searchTerm == "" && activity == "") {
clubService.getClubs().then(function(clubs) {
$scope.clubs = clubs;
console.log($scope.clubs);
});
} else if (searchTerm != "" && activity == "") {
} else if (searchTerm == "" && activity == "") {
} else if (searchTerm != "" && activity != "") {
}
이 CONSOLE.LOG의 결과이다 (당신은 결과가 있음을 알 수 그들은 맞다)
Object { id="1", a_id="["2","6","11","13","14",...8","69","76","84","97"]", title="Ashington Leisure Centre", more...}, Object { id="2", a_id="null", title="Beach Huts", more...}, Object { id="3", a_id="["2","6","11","13","14",...","70","76","84","105"]", title="Blyth Sports Centre",
누구나 $ scope.clubs 변수가 내보기에서 ng-repeat에 자체적으로 핑핑하지 않는 이유를 알 수 있습니까? 감사
아 내 말을. 감사 – devoncrazylegs