[英]Angular js-User automatically likes a program
I am new to angular js.. I have implemented a website with Ruby on rails and angular in which a user can like a program..But in a peculiar scenario whenever a user clicks on a program,the program page will automatically show that the user likes the program,whether he has clicked on the like button or not. 我是angular js的新手。.我已经在Ruby和Rails上实现了一个网站,用户可以在其中喜欢一个程序。但是在特殊情况下,只要用户单击某个程序,程序页面就会自动显示用户喜欢该程序,无论是否单击了“喜欢”按钮。 and his facebook profile pic is shown
和他的Facebook个人资料照片显示
The following is the Javascript code:- 以下是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();
});
}]);
My Html is as Follows:- 我的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>
Please help me with this 请在这件事上给予我帮助
I don't think your problem is in the FriendsController , it's just responsible for populating that scope with information from the userAPI . 我认为您的问题不在于FriendsController中 ,它只是负责使用userAPI中的信息填充该范围。 I noticed that there's some more logic in this template from another controller - not sure which:
我注意到另一个控制器在此模板中还有更多逻辑-不知道哪个:
<li class="logo" ng-click="shareLinkOnFb()"></li>
Take a look at whichever controller has the scope function shareLinkOnFb and see what it is doing. 看一下具有作用域函数shareLinkOnFb的任何控制器,然后看看它在做什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.