0

Based on this link here How do I share $scope data between states in angularjs ui-router? data is being shared on different states using the same controller. Is it possible to achieve the same thing using different ui-router files though?

I have a project that has two ui-router.js files(they are both on the same domain). So can I bind the data from the parent scope on one state to other states on a different ui-router file?

Community
  • 1
  • 1
Elly Bolson
  • 31
  • 1
  • 7

1 Answers1

0

Use services.Services are singletons, so you can store any variables there.

app.service('sessionService', function($http, settings){
    var that = this;
    this.userSessionData = null;

    this.setUserSessionData = function(sessionData) {
        that.userSessionData = sessionData;
    }

    this.getUserSessionData = function() {
        return that.userSessionData;
    };
});
Ivan Ursul
  • 3,251
  • 3
  • 18
  • 30