Json contains url


#1

Hi All,

In my app i am giving the sample json which contains the url. In my app i used the list to display the contents of the json and when we tap the list item to show the another view but i having the issue when the parsed json array which having the url is not going to another view but the url is not the valid url its moving to next view.

i am giving the sample json

[
                  {
                  "title": "Multiple Ajax Image Upload without Refreshing Page using Jquery.",
                  "banner": "multiple.jpg",
                  "description": "Some Text",
                  "time": "Tuesday, August 6, 2013",
                  "author": "Srinivas Tamana",
                  "image": [
                            {
                            "url": "https://dl.dropboxusercontent.com/u/12786982/book.jpg",
                            "thumbnail_url": "YYYYYYYY"
                            }
                            ]
                  },
                  {
                  "title": "Wall Script 6.0",
                  "banner": "WallBanner.jpg",
                  "description": "Some Text",
                  "time": "MONDAY, JULY 29, 2013",
                  "author": "Srinivas Tamada",
                  "image": [
                            {
                            "url": "ppppppppppppp",
                            "thumbnail_url": "qqqqqqqqqqq"
                            }
                            ]
                  }
                  ]

In the list i am getting the two list item when i tapped the first list item its not moving but when i tap the second its moving.

Thanks in advance for helping me the issue…

cheers
Balamurugan


#2

hey please use backticks next time to put into your post or use something like codepen
e.g.
hello

Do you might post us your template and controller code?

Greets, bengtler


#3

Thanks @bengtler
i have create a project using the side menu template in ionic framework.

this is my .html

<ion-view title="Books">
<ion-nav-buttons side="left">
<button menu-toggle="left" class="button button-icon icon ion-navicon"></button>
</ion-nav-buttons>
<ion-content class="has-header">
<div class="list">
<a ng-repeat="playlist in playlists" class="item item-thumbnail-left"href="#/app/playlists/{{playlist}}">
<img ng-repeat="image_url in playlist.image" src="{{ image_url.url }}">
<h2>{{ playlist.author }}</h2>
<p>{{ playlist.time }}</p>
</a>
</div>
</ion-content>
</ion-view>

this is my controller

'use strict';

angular.module('starter.controllers', [])

.controller('AppCtrl', function($scope) {
})

.controller('PlaylistsCtrl', function($scope, $http, $rootScope, simplefactory) {

$scope.playlists = [];
init();

function init() {
$scope.playlists = simplefactory.getlists();
}

})

.controller('PlaylistCtrl', function($scope, $stateParams) {

       `$scope.time = $stateParams.playlist;`

})

.factory('simplefactory', function() {
var lists = [
{
"title": "Multiple Ajax Image Upload without Refreshing Page using Jquery.",
"banner": "multiple.jpg",
"description": "Some Text",
"time": "Tuesday, August 6, 2013",
"author": "Srinivas Tamana",
"image": [
{
"url": "xxxxxxx",
"thumbnail_url": "YYYYYYYY"
}
]
},
{
"title": "Wall Script 6.0",
"banner": "WallBanner.jpg",
"description": "Some Text",
"time": "MONDAY, JULY 29, 2013",
"author": "Srinivas Tamada",
"image": [
{
"url": "https://dl.dropboxusercontent.com/u/12786982/book.jpg",
"thumbnail_url": "qqqqqqqqqqq"
}
]
},
{
"title": "Wall Script 6.0",
"banner": "WallBanner.jpg",
"description": "Some Text",
"time": "MONDAY, JULY 29, 2013",
"author": "Srinivas",
"image": [
{
"url": "dddddddddddd",
"thumbnail_url": "qqqqqqqqqqq"
}
]
}
]
var factory = {};
factory.getlists = function() {
return lists;
};
factory.postlists = function() {

};
return factory;
});

when i tap the first and third list item it showing the another view but when i tap the second item it not moving to another view.

when i remove the url from the second and giving any other text its working.
cheers
Balamurugan


#4

This is because external urls need to declared as safe. This is to prevent any negative cross site scripting.