I have two pages. One is list and its detail page. Both the page’s data is coming from a single json. I have two controllers for both the pages. I want to use same json in two controllers with a single call. The json structure is something like this:
[
{
"tid": "3388",
"name": "Adagio Bar",
"description": "Choose to enjoy one of our Italian inspired cocktails while taking in the spectacular views or simply relax.
"field_location_category": "Aft",
"category_tid": "351",
"category_name": "Entertainment/Bars",
"deck": "Sun Deck 16"
},
{
"tid": "3439",
"name": "Botticelli Dining Room",
"description": "A sumptuous variety of dining options awaits you on every voyage.
"field_location_category": "Aft",
"category_tid": "350",
"category_name": "Food and Dining",
"deck": "Fiesta Deck 6"
}
]
When we press the list page the url like this “list/tid”
How to point out corresponding list to its details?
Controller
'use strict';
var app = angular.module('Location', []);
app.controller("Location", function($scope, $http){<br/>
$scope.locationList = null;
$http.get("sites/all/modules/custom/locations/location.json")
.success(function(data){
$scope.locationList = data;
var indexedloc = [];
$scope.locationListToFilter = function(){
indexedloc = [];
return $scope.locationList;
}
$scope.filterLocation = function(Loc){
var locationIsNew = indexedloc.indexOf(Loc.category_name) == -1;
if(locationIsNew){
indexedloc.push(Loc.category_name);
}
return locationIsNew;
}
$scope.returnFilterLoc = function(){return indexedloc};
})
.error(function(data) {
$("div.content").html("Error");
});
});<br/>
app.controller("LocationDetail", function($scope, $http){
$scope.locationDetail = null;
$http.get("sites/all/modules/custom/locations/location.json")
.success(function(data){
$scope.locationDetail = data;
})<br/>
.error(function(data) {
$("div.content").html("Error");
});
});
I have added html for list page and its detail page in the following link http://jsfiddle.net/cAY2N/14/
Please help. Thanks in advance.