Passing data between controller/views

I am having trouble passing data between controllers using a service. What i want to happen is when send data is clicked the data inputted into the text field should be populated in the Results controller. However nothing shows

please take care of the code formatting… or make a codepen… in othercase nobody will help you, because you code is not readable

Sorry didn’t realize… I updated it with codepen link

Hi sirsaula,

I just made a codepen from yours, where I share datas between two controllers using a service:


Hope it helps you.

It must be how i am switching views that is resetting the data, because things work fine on the same page but however when i need the data to load on another view it seems to call the app.factory again and resets the data. Here is the issue when the app is FIRST loaded and the calculate button is hit… when it switches to the results view the data does not appear… however any subsequent clicks of calculate the result page properly shows the persisted data

Here is my JS code that handles the views

//Creates the views and associated controller
app.config(function ($stateProvider, $ionicConfigProvider) {
    //Forces tabs to bottom on all OS

            .state('home', {
                url: '/home',
                views: {
                    home: {
                        templateUrl: 'home.html'


            .state('results', {
                url: '/results',
                views: {
                    results: {
                        templateUrl: 'results.html',
                        controller: 'ResultsController'



Haha figured it out. Yes it turned out it was the way i was calling the results page… I had to remove form tag and change my button to call the results page as such