My table view triggers the PixCtrl
controller when a cell is clicked. If the connection is successful, data is retrieved using $http.get
, otherwise sqlite is used. This setup works fine. However, I am facing an issue with my ion-nav-buttons
being dynamic. Initially, it does not work on the first click; only after clicking again will it show up. I have tried monitoring it through the console and everything seems correct each time. How can I resolve this problem with the first click?
Thank you for your assistance.
controller
.controller('PixCtrl', function($scope, $sce, $stateParams, SQLService, $http....) {
...
if ( ! $rootScope.noConnection) {
$http.get('http://pixnettest-lighter.c9.io/content.php?id=' + $stateParams.pixnetId)
.success(function(data, status, headers, config) {
var pix_data = {
...
html_comment_count: datas[0].comment_count,
...
};
$scope.pix_content = pix_data;
});
}
else {
// Get data from sqlite
var pixnet_data = {
...
html_comment_count: content.comment_count,
...
};
$scope.pix_content = pix_data;
}
...
$scope.checkMComBtn = function(comment_count) {
var intValue = parseInt(comment_count) || 0;
console.log('intValue ' , intValue);
if (intValue > 0) {
return 1;
}
else {
return 0;
}
}
});
view
<ion-view on-swipe-right="onSwipeRight()" ng-init="initEvent()">
<ion-nav-buttons side="right" ng-if="checkMComBtn(pix_content.html_comment_count)">
<button class="button">Message</button>
</ion-nav-buttons>
...
</ion-view>