vendredi 3 octobre 2014

Angular controller variables not showing


Vote count:

0




I have built a small Angular component into one of my websites that I am having a few issues with. I have defined a controller for my application but the view is not pulling through any of the variables or functions from the controller and I am not sure why. Here is my code:


This is my file to define the controllers:



angular.module('clubFilter.controllers', []).
controller('clubController', function($scope, $http, googleMapService) {
$scope.clubsJSON = JSONItems;
$scope.clubs = $scope.clubsJSON;
if(searchTerm == "" && activity == "") {
$scope.clubs = $scope.clubsJSON;
console.log($scope.clubs);
} else if (searchTerm != "" && activity == "") {

} else if (searchTerm == "" && activity == "") {

} else if (searchTerm != "" && activity != "") {

}
........


Here is my angular app file:



var clubFilter = angular.module("clubFilter", [
'clubFilter.controllers',
'clubFilter.services'


]);


And here is my HTML view:



<div ng-app="clubFilter" ng-cloak class="col-lg-12" ng-controller="clubController as clubItem">
<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://ift.tt/1tmxFQ0}}">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>


When the page loads, the $scope.clubs object is supposed to be looped through and then show in an ng-repeat in the view. This doesn't not seem to be happening though, Can anyone see why this is not working? I have checked the structure of the object and it is fine and has been working before. Thanks



asked 19 secs ago







Angular controller variables not showing

Aucun commentaire:

Enregistrer un commentaire