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 ( 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:
Here is my code:




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

app.config(function($stateProvider, $urlRouterProvider) {
   .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){
      	.success(function (response) 
       $scope.names = response;
app.controller('myjson', function($scope, $http) {
      $scope.detail = function(click){
      alert('Clicked: '+click)
      	.success(function (responses) 
      	//$scope.namea = ;     	
       $scope.tite = responses; 

my json files
[{“Title” : “Frozen”, “Year” : “2003”, “img”:“”} , {“Title” : “Furious 7”, “Year” : “2015”, “img” : “”}, {“Title” : “San Andreas”, “Year” : “2015”, “img”:“”}]

{“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