Tom
Tom

Reputation: 4097

Ionic/Angularjs: pass data back from detail to master

In Ionic (but in general in angularjs) i have a Master/Detail pages: in the Detail page i select some data and i want pass this data back to the Master controller.

How can i achieve it in angularjs?

Upvotes: 0

Views: 98

Answers (1)

matt93
matt93

Reputation: 366

use factories / services for sharing data between controllers

example:

myCtl.js

angular

    .module('app')
    .controller('myCtl', myCtl);

function myCtl(sharedDataFactory) {

   var vm = this;

   vm.someValue = sharedDataFactory.getMySharedValue();
   vm.setSomeValue = sharedDataFactory.setMySharedValue;

}

any controller in your app may use sharedDataFactory, where you have your shared value and get/set methods

you may get the idea

hope this helps

Upvotes: 2

Related Questions