I have two pages in my angularjs application, I get some data from database to show in a table, then i doubleclick on a row and go to another page to show more details. The problem consists on how to send data from the first page to the second one to show them knowing that i have all the data i need to show in my variable “branchs” that i showed some of them in the first page, here is a part of my code :
If you’re wanting to share data between two or more controllers (or components) in an Angular 1 app, then you can create a service that they can require as a dependency and do the data fetching there.
From your code example, though, it looks like you’re redirecting to a separate page, so any state in the current app will be lost.
Hi @fretburner !
I ve created a service but getdetails method doesn’t work , i tested by setting a value to my var v inside the service and it works, but when i want to set some value to my service in the controller it fails to set data that i want to send , look at this code :
As I said before, it looks like you’re redirecting to a separate page, with a second Angular app on it, is that right? If so, is there any reason for doing that, as opposed to using routing within your app to display a different view?
@fretburner
Yes, that’s right, i’m redirecting to another page with a second angular app, i did it for no reason just because i’m a beginner with angularjs and i didn’t think at using views… so will that be easy to display my data with factories without problem using views ?
Hi!
Now I’m using views but i still have a problem that is I don’t know how to change the view when i dblclick on a table row, i mean how to send the path of the view to show within the dblclick function !
Require the $location service in your view controller, and call $location.path() passing in the route that you want to navigate to. You can then trigger this from your view with an ng-dblclick attribute.
yees i succeed to access my new view, but there is still a small problem, when the view is shown it repeats the content of my home page
thanks a lot @fretburner for replying