seyid yagmur seyid yagmur - 1 year ago 83
AngularJS Question

Ionic send data when routing another page

I 'got a problem.I want to send data from my home.html page to map.html page.So I am trying to pass the data from HomeController to MapController.But I don't want to use Service..
I am looking for a solution sending data simply by using $state.go or anything else...



do you know any solution for me?
thanks in advance!!

Answer Source

You've started totally right.

In you state, define the params expected, example:

.state('', {
  url: '/compare/info',
  params: {
    map: null
  template: '<p></p>',
  controller: 'Ctrl'

and call the route with

$state.go('', {map: object});

Inside the destination state controller, inject $stateParam and get the parameter:

function Ctrl($stateParams) {
    var map = $;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download