How to use two controllers in two template pages

Hello… I am a new user to Ionic Framework. Help me pls…

My app will have two pages… home and detail view(in my case “state1”). these two are template called into index.
Home page will fetch data from json containing Name and Year. When I click on one Name, it will go to detail view and fetch again json from remote url like (http://www.url.com/?t=Name) and get others informations of NAME.
I use one controller for home to get json and another controller for detail view.
I can fetch json data for detail view but i can’t show it in detail view page… help me how to solve :smiley:
THANKS
Here is my code:

index.html


 
  
 
 
 

app.js

var app = angular.module('starter', ['ionic'])

app.config(function($stateProvider, $urlRouterProvider) {
   $urlRouterProvider.otherwise('/')
   $stateProvider
   .state('home', { url: '/', templateUrl: 'templates/home.html',controller: 'test'})
   .state('state1', {url: '/state1', templateUrl: 'templates/state1.html',controller: 'myjson'})
 }); 
app.controller('test', function($scope, $http){
 	
 $http.get("http://localhost/list.json")
      	.success(function (response) 
      	{
      		
       $scope.names = response;
      });		
 });      
app.controller('myjson', function($scope, $http) {
      	
      $scope.detail = function(click){
      alert('Clicked: '+click)
      $http.get("http://localhost/list1.json")
      	.success(function (responses) 
      	{    	
      	//$scope.namea = ;     	
       $scope.tite = responses; 
       //alert(responses["Year"])   
      });		
      }	      	
});

my json files
list.json
[{“Title” : “Frozen”, “Year” : “2003”, “img”:“http://ia.media-imdb.com/images/M/MV5BMTQ1MjQwMTE5OF5BMl5BanBnXkFtZTgwNjk3MTcyMDE@._V1_SX300.jpg”} , {“Title” : “Furious 7”, “Year” : “2015”, “img” : “http://ia.media-imdb.com/images/M/MV5BMTQxOTA2NDUzOV5BMl5BanBnXkFtZTgwNzY2MTMxMzE@._V1_SX300.jpg”}, {“Title” : “San Andreas”, “Year” : “2015”, “img”:“http://ia.media-imdb.com/images/M/MV5BNjI4MTgyOTAxOV5BMl5BanBnXkFtZTgwMjQwOTA4NTE@._V1_SX300.jpg”}]

list.json
{“Title” : “Frozen”, “Year” : “2003”}

Someone help me pls!!

what’s wrong

Have you tried put the json data on a service?
Then you can import and use it on both controllers

Yes! Thanks… It works… i use service to push data