Привет Я работаю над проектом на основе angularjs и загрузка данных json..There проблема я застрял с и не получить решение ..Angularjs: - изменение кнопки на основе JSON данных
ниже приведен код HTML: -
<div owl-carousel-item="" ng-repeat="profile in updatedProfile" ng-if= "profile.show">
<!-- Panel in owl carousel -->
<div id="discover " ng-class="discover_image">
<li style="margin-left:0px; margin-right:0px">
<div class="thumbnail_photo">
<button class="close" ng-click="remove(profile)"><span class="glyphicon glyphicon-remove"></span></button>
<a href="#/discover/{{profile.basic.username}} " target="_blank"><span class="discover_pic_container" style="background:url({{profile.photo_details.photos[0].domain_name+profile.photo_details.photos[0].medium}}) no-repeat center top"></span></a>
<div class="discover_transparent">
<div class="discover_name">{{profile.basic.display_name }}</div>
</div>
</div>
<div class="recent_join_user_info">23 yrs, 5'4", Gujarati, Hindu Mumbai, India</div>
<button class="discover_connect_btn btn btn-lg " ng-click="connect(profile)" ng-if="member">Connect</button>
</li>
</div>
</div>
ниже мой код контроллера сниппет: -
AppControllers.controller('ProfileListCtrl', ['$scope', 'ProfileData', '$timeout', function($scope, ProfileData, $timeout) {
//Profile data above is a factory created to connect with the discovery.json
var promise = ProfileData.query();
promise.$promise.then(function(response) {
$scope.profile = response.data;
// console.log($scope.profile);
var profile = $scope.profile;
for (i = 0; i < profile.length; i++) {
// console.log(data[0].account.membership)
profile[i]["show"] = true;
// console.log(profile[i]);
//console.log(profile[i].account.membership)
if(profile[i].account.membership == "free")
{
console.log("This account is free");
$scope.member=true;
}
else if(profile[i].account.membership == "premium")
{
console.log("This acocunti snot");
$scope.member=false;
}
else
{
console.log("unknown member")
}
}
$scope.alert_message = "Sorry! You don't have any Shortlisted Profile to check";
$scope.seeAllUrl = "member_who_shortlisted_you";
// Get the size of an object
var totalNumberOfProfile = profile.length;
//console.log(totalNumberOfProfile);
$scope.totalNumberOfProfile = totalNumberOfProfile;
$scope.categoryOfProfile = "Member Who Shortlisted You";
Теперь я хочу, чтобы изменить кнопку в зависимости от членства счета я получаю от JSON е Ile ..
По default it is Connect but have three more button for different conditions
..
Я пытался использовать нг-если и застрять и понятия не имеют, как изменить кнопки на основе данных ..
Я новичок на angular..please помочь мне out..Thanks
с помощью какой параметр вы должны изменить кнопку? –
Можете ли вы сделать скрипку/плункер? –
@RajaSekar Я использовал ng-if = "member" и в контроллере поставил $ scope.member = true, поэтому я могу отображать кнопку для члена, чья учетная запись бесплатна –