我是棱角分明的新手.. 我已经实现了一个带有Ruby on rails和angular的网站,用户可以在其中喜欢一个程序。但是在用户点击某个程序的特殊情况下,程序页面会自动显示用户喜欢该程序,不管他有没有是否点击了类似按钮。和他的facebook个人资料照片显示
以下是Javascript代码: -
woi.controller("FriendsController", ['$scope', '$rootScope', '$routeParams', '$filter', 'userAPI', function($scope, $rootScope, $routeParams, $filter, userAPI){
$scope.recommended = [];
$scope.paginate = [];
$scope.friends = [];
$scope.amount = 0;
$scope.step = 5;
$scope.showMore = true;
if($rootScope.device.isTablet){
$scope.step = 30;
}
if($rootScope.device.isMobile){
$scope.step = 20;
}
$scope.loadMore = function(){
if(!$scope.friends.length)
return false;
$scope.amount= $scope.amount + $scope.step;
if($scope.amount >= $scope.friends.length){
$scope.showMore = false;
$scope.amount = $scope.friends.length;
}
$scope.paginate = $scope.friends.slice(0, $scope.amount);
};
userAPI.friends({programmeid:$rootScope.Programmeid}, function(rs){
if(!rs.getpeoplielikeprogram)
return false;
$scope.friends = addData(rs.getpeoplielikeprogram.peoplielikeprogram);
$scope.loadMore();
});
}]);
我的Html如下: -
<div class="available-in" ng-show="showAvailableIn" ng-controller="AvailableInController">
<h6 class="subtitle">AVAILABLE IN</h6>
<ul class="list-available">
<li ng-repeat="channel in availableIn">
<a href="{{channel.storeurl}}"><img ng-src="{{channel.logofileurl}}" alt="{{channel.storeinformation}}" /></a>
</li>
</ul>
</div>
<!-- / availableIn -->
<div class="friends" ng-show="friends.length>0" ng-controller="FriendsController">
<h6 class="subtitle">FRIENDS</h6>
<ul class="list-friends">
<p class="title_pink">{{friends[0].username}}<span class="text_woi"><span ng-show="friends.length - 1 > 0"> and {{friends.length-1}} others</span> liked it</span></p>
<li class="item animate bounceInDown clearfix friend_inline_list" ng-repeat="r in paginate" >
<div class="thumb" css-bg-image="../assets/img/cast-default.png">
<div css-bg-image="{{r.userimage | filterDefaultImage}}" title="{{r.username}}"> </div>
</div>
</li>
</ul>
<p class="loadmore" ng-show="showMore">
<a href="javascript:void(0);" title="Load more Recommended" ng-click="loadMore()">More..</a>
</p>
</div>
<!-- / friends -->
<!-- Share with friends -->
<!-- <div class="friends" ng-controller="FbShareController" style="margin-top:30px;" ng-show="userLogged=='on'" > -->
<div class="friends" style="margin-top:30px;" ng-show="userLogged=='on'" >
<ul class="list-friends list_share_friends">
<li class="logo" ng-click="shareLinkOnFb()"></li>
<li class="logo_text" ng-click="shareLinkOnFb()">Share with Friends</li>
<li class="clearfix"></li>
</ul>
</div>
<div class="feed fb" ng-show="showFacebook==true && paginateFb.length > 0">
<ul>
<li class="colorfull">
<h6 class="subtitle">FB newsfeed</h6>
<a ng-click="loadMoreFb()">{{fbText}}</a>
</li>
<li class="item clearfix" ng-repeat="post in paginateFb">
<div class="thumb">
<div class="wrapper">
<img ng-src="{{facebookProfilePic}}">
</div>
</div>
<div class="info">
<span class="account-name">{{post.from.name}}</span>
<!-- <div class="post">
{{post.message}}
<br/>
<img ng-src="{{post.picture}}">
</div> -->
<div class="post" ng-bind-html>
<span ng-bind-html-unsafe="post.message | replaceLinks"></span><br/>
<img ng-src="{{post.picture}}">
</div>
<br/>
<span class="time">{{post.updated_time|facebookTime}}</span>
</div>
</li>
</ul>
</div>
<!-- / feed facebook -->
<div class="feed twitter" ng-show="showTwitter==true && paginateTwitter.length > 0">
<ul>
<li class="colorfull">
<h6 class="subtitle">Twitter</h6>
<a ng-click="loadMoreTweets()">{{twitterText}}</a>
</li>
<li class="item clearfix" ng-repeat="post in paginateTwitter">
<div class="thumb">
<div class="wrapper">
<img ng-src="{{post.user.profile_image_url}}">
</div>
</div>
<div class="info">
<span class="account-name">{{post.user.name}} </span>
<div class="post" ng-bind-html>
<span ng-bind-html-unsafe="post.text | replaceLinks"></span>
</div>
<span class="time">{{post.created_at|twitterTime}}</span>
</div>
</li>
</ul>
</div>
</aside>
请帮我解决这个问题
答案 0 :(得分:0)
我认为您的问题不在 FriendsController 中,它只负责使用 userAPI 中的信息填充该范围。我注意到另一个控制器在这个模板中还有一些逻辑 - 不确定是哪个:
<li class="logo" ng-click="shareLinkOnFb()"></li>
看一下具有作用域 shareLinkOnFb 的控制器,看看它在做什么。