0

I am trying to pass the data from one html to another html page after clicking on particular table row but unable to send the data.

RasikaP
  • 1
  • 2

3 Answers3

1

You can share data between two controllers by

  1. $rootScope - assign a value and use the same in other controller
  2. Via URL Parameter : specify param in config and use $stateParams or $routeParams
  3. Service or Factory

Ref :

URL Parameter example : pass data between controllers

Service or Factory : https://thinkster.io/a-better-way-to-learn-angularjs/services,

Service or Factory : https://egghead.io/lessons/angularjs-sharing-data-between-controllers

Community
  • 1
  • 1
  • I have tried using factory. I am able to set the values but then when another page navigates values get reset again. Unable to return the values which have been set – RasikaP Nov 25 '16 at 10:27
0

You can call set function of factory to store data in object from controller.

then after opening second html, call get function of factory which will return stored object to you. In this way you can pass data to any html page.

Hope this will helpful to you.

Avinash Rathod
  • 590
  • 4
  • 15
  • I have tried using factory. I am able to set the values but then when another page navigates values get reset again. Unable to return the values which have been set – RasikaP Nov 25 '16 at 11:25
0

You can use $rootScope to set data globally which will be applicable for all the pages inside an angularjs application.

var app = angular.module('app',[]).run(function($rootScope){ $rootScope.userName = "xyz"; });

You can also pass data in URL of the page

Arun Kasyakar
  • 905
  • 8
  • 9