Ionic Tabs and JSON strange behaviour


#1

Hi there!

I have an ionic app using tabs template, and one of the tabs render json feed (blogs) but just a list with the titels and if tou tap, you go to the full article. Is only one big feed for this section.
The html looks like this:`


				<div id="json" class="list blogCss" ng-repeat="item in data" ng-click="moveToSumary(item)">
					<a class="item item-thumbnail-left noBlank" href="#">
						<div class="item-image">
							<img data-ng-src="{{item.image}}" alt=""/>
						</div>
						<h2>{{item.title}}</h2>

						<p>{{item.pubDate | limitTo: 16}}</p>

						<div {{ng-bind-html="item.description | limitTo: 16 " }}></div>
					</a>
				</div>

				
		</div>`

I also have another tab (news) that render a different JSON feed but in the same way.

Everything works well, but if you for example open an blog article and then move in to the news tab, open one, and then come back to blog, go back to the list of all blogs and choose another post the json is not rendered anymore (the template is coming with all the tags but it looks like there is no JSON there)

I know this may be confusing, but i wonder if anyone know something about this issue,

Thank you!


#2

Do you fetch your json data within an $ionicView event block?


#3

I’m not sure what are you trying to say.
The controller for the blog list looks like this :smile:

	.controller('blogCtrl', function ($scope, $http, Chats, $state) {
	$scope.data = [];
	
	$http.get("https://www.thewebsite.org.uk/index.php?option=com_obrss&task=feed&id=12:blog-feed-all&format=json").
		success(function (data, status, headers, config) {
			Chats.setBlogData(data.value.items);
			$scope.data = data.value.items;		
		});

	$scope.moveToSumary = function (item) {
		$state.go('tab.summary', {title: item.title});
	}
	
})

and the summary looks like this:

.controller('summaryCtrl', function ($scope, Chats, $state, $http) {
	$scope.isloggedIn = Chats.getLoggedIn();
	var userData = Chats.getProfileData();
	$scope.data = Chats.getspecificBlogData($state.params.title);


	$scope.user = {
		comment: ""
	};
	$scope.commentButtonClicked = function () {
		var url = "http://www.thewebsite.org.uk/index.php?option=com_yonescatapi&task=comment&";
		url = url + "author=" + userData.name + "&email=" + userData.email + "&content=" + $scope.user.comment + "&item_id=" + $scope.data.Item_id + "&state=0";
		url = encodeURI(url);
		$http.get(url).
			success(function (data, status, headers, config) {
				alert("Your comment was successfully submitted.One of our administrators will check it before publishing");
				$scope.user = {
					comment: ""
				};
				buttons: [
						{ text:'OK'},
						
						]
			}).error(function (data) {
				console.log(data);
			});
	}
	$scope.loginToComment = function () {
		$state.go('tab.login');
	}

})

#4

ohh sorry yes… i do that:

At the beginning of the html document i have <ion-view view-title="Blog"> on both the list and the summary.


#5

Or i’ m even thinking of making the page automatically refresh after is opened.Anyone know how can this be implemented is this situation?


#6

I meant this:

$scope.$on('$ionicView.beforeEnter', function () {
  // fetch data here to work around Ionic's view caching
 $http.get(url).....
});

#7

no … i can t see anything like this in the code.