-1

I am facing problem to manage the data while redirecting from one page to another in angulrJS.

I have one page (Tyre Card) where few fields like Name, address, isPersonalUser etc... From this page user can go into another page (Vehicle card) where few fields like regNo, vehicle type etc...

Two different controllers are there. Tyre Card and Vehicle card are linked using FK.

When user do some changes into TyreCard and navigate to another page(Vehicle card). I want to manage data of Tyre card, so when user back to this page from vehicle card then those data should be there on Tyrehotelcard.

m.s.
  • 16,063
  • 7
  • 53
  • 88
user2656435
  • 43
  • 1
  • 4
  • you can assign commom fields in main module ex:$rootscope.fieldname fieldname assign in controller you can use another controller – Ashokreddy Oct 19 '15 at 06:26

4 Answers4

-1

AngularJS is Single Page Application(SPA). So the idea of the angular application is to design an application with only one page.

So you cannot pass data from one page to another.

What you can use is partials and use ngRoute to navigate from one partials to another within the same page.

See ngRoute documentation

Fracedo
  • 626
  • 7
  • 23
-1
angular.module('ContentApp').run(function ($rootScope) {
        $rootScope.TyreCard  = null;
     })
})();



    angular.module('ContentApp')
        .controller('ContentCtrl', ContentCtrl)



 ContentCtrl.$inject = ['$scope', '$rootScope', 'api'];


 function ContentCtrl($scope, $rootScope, api) {

    $rootScope.TyreCard=typecard

}
Ashokreddy
  • 352
  • 1
  • 11
-1

In case you're application is a single page app, the most common solution is to use a Factory (single instance) injected to both controllers, as described here: Share data between AngularJS controllers

Community
  • 1
  • 1
-1

I found the solution. I will use sessionstorage.

Tyre Card data stored here. vm.createSessionStorage("TyreHotelCardData", vm.data);

When I will back from vehicle page to Tyre card page.

var result = vm.getSessionStorage("TyreHotelCardData");

So in result I will have the Tyrecard data.

user2656435
  • 43
  • 1
  • 4