Lemon Lemon - 2 years ago 122
Javascript Question

Passing data from controller to another controller

I am working on sails JS application.

Is there anyway to pass a data from another controller using sails JS?

// controller 1
passing data to controller 2

// controller2

get data from controller 1

or better, is there anyway to create a global variable which can be accessed by any controller in sails js? just like $_SESSION['sessionname'] in php?

Answer Source

You can use a Service, it enables you to access data everywhere in your code.


You can also use the global variable sails:

sails.myObject = {}

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download