1

I need some help from you guys I am new in AngularJs, I have code there is too long code thats why I upload doc file, please check it below link, Using the code snippet below I'm authenticating email, password. The customerlogin() method returns some JSON data which I want to show in the next page. In other words I want to pass the data returned from customerlogin() to then() and then pass it to /customerprofil

Please help, my boss tell me follow this code but how to transfer data other page and show using angular js, my code is different you show dublicats

Code is there

<div class="panel-body" ng-app="agfullstackApp.customerprofile">
    <form action="">
        <div class="form-group" ng-controller="customerprofileComponent">
            <label class="col-md-2 control-label" for="inputDefault">{{full_name}}</label>
        </div>
Al Foиce ѫ
  • 4,195
  • 12
  • 39
  • 49
Adeel Khan
  • 129
  • 2
  • 13

1 Answers1

0

You can use angular service to share the data between pages. But the data will be lost if you re-fresh the page. Following is an example using service.

angular.module('myServiceModule',[])
.service('myService', function() {
    var savedData = {}
    this.setData  = function(data) {
        savedData = data;
    }
    this.getData = function() {
        return savedData;
    }
});

Then set data from controller 1.

app.controller('View1Ctrl', ['myService', function(myService) {
    myService.setData("some data from view 1")  ;
}]);

To get the data from controller 2.

app.controller('View2Ctrl', ['myService', function(myService) {
    console.log(myService.getData());
}]);

If you want your data available even after page refresh, you need to use localStorage. https://github.com/grevory/angular-local-storage (It is better to use angular-local-storage module as it support cookie fallback in case of unsupported browsers or storage capacity problems)

Paulson Peter
  • 574
  • 4
  • 12