Angularjs 角度控制器变量未显示
我已经在我的一个网站上建立了一个小的角度组件,我有一些问题。 我已经为我的应用程序定义了一个控制器,但是视图没有从控制器中提取任何变量或函数,我不知道为什么。 这是我的密码: 这是我定义控制器的文件:Angularjs 角度控制器变量未显示,angularjs,Angularjs,我已经在我的一个网站上建立了一个小的角度组件,我有一些问题。 我已经为我的应用程序定义了一个控制器,但是视图没有从控制器中提取任何变量或函数,我不知道为什么。 这是我的密码: 这是我定义控制器的文件: angular.module('clubFilter.controllers', []). controller('clubController', function($scope, $http, googleMapService) { $scope.clubsJSON = JSONIte
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 != "") {
}
........
这是我的angular应用程序文件:
var clubFilter = angular.module("clubFilter", [
'clubFilter.controllers',
'clubFilter.services'
]))
这是我的HTML视图:
<div ng-app="clubFilter" ng-cloak class="col-lg-12" ng-controller="clubController">
<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>
位置:{{searchTerm}
活动:{{activityText}
(以英里表示的距离)
您最近的休闲中心有{{activityText}}设施
-
{{俱乐部名称}
{{俱乐部大楼},
{{俱乐部街},
{{俱乐部.城市},
{{club.county}},
{{俱乐部.邮政编码}
电话:
电子邮件:
加载页面时,$scope.clubs对象应该循环通过,然后在视图中以ng repeat的形式显示。但这似乎没有发生,有人能理解为什么这不起作用吗?我已经检查了对象的结构,它很好,并且以前一直在工作。
谢谢
编辑以添加JSONitems对象结构:
[
Object {
id="1",
title="Ashington Leisure Centre",
description="<p>Ashington Leisure Cen...ase give us a call.</p>", more...},
Object {
id="2",
title="Beach Huts",
description="<p>A trip to the beautif...ings - 01670 542222</p>", more...},
Object {
........
[
对象{
id=“1”,
title=“阿辛顿休闲中心”,
description=“阿辛顿休闲中心…请给我们打电话。”,更多…},
对象{
id=“2”,
title=“海滩小屋”,
description=“美丽之旅-01670 542222”,更多…),
对象{
........
您为控制器添加了别名,但未使用别名访问数据
<li ng-repeat="club in clubItem.clubs" ng-show="club.show">
//应用程序
角度模块('clubFilter',['ClubFilterController']))
//控制器
clubFilterControllers.controller('viewController',['$scope','$http','googleMapService',',
函数($scope,$http,googleMapService){
/*这里的逻辑*/
}])
控制器中的JSONItems从何而来?它是一个在view.html中定义的Javascript对象(它是一个Joomla自定义组件)。它在console.log显示对象中的项时正常工作,我以前也有过这种工作。我在作用域中添加了一个测试作用域变量(只是一个字符串)它似乎很有效。它不再喜欢我的$scope.clubs对象了,这和以前一样奇怪。它来自PHP,是JSON编码的。这是一个问题吗?对不起,这是我的一个错误。我去掉了别名,但忘了复制正确的代码。代码在最初的问题中已经修改,我仍然拥有范围e错误。