0

I have a page wherein I display a list of items in a table. There is a field named 'Details', after clicking which goes to the view displaying details of the particular item. Values being displayed on 'details.html' are correct, but I am using a static value of the item. I want to get the id of the clicked item so as to display its details. Both the html pages in views are having two different controllers, which I don't want to merge. So, how can I pass the values from one controller to another on the fly? Kindly Help!

<table class="table table-hover">
<tr>
  <th>DOCTOR</th>
  <th>SPECIALITY</th>
  <th>CITY</th>
  <th>CLASS</th>
</tr>
<tr ng-repeat="doc in doctors">
  <td>{{ doc.contactName }}</td>
  <td>{{ doc.speciality }}</td>
  <td>{{ doc.townName }}</td>
  <td>{{ doc.class }}</td>
  <td><a href="#/precall" ng-click="pass(doc.contactId)">&gt</a></td>
</tr>

for this I use controller MenuCtrl. On click this should go to next page which uses PrecallCtrl. I want to display following thing on it.

<h2>{{contactid}}</h2>

getting contactid id is enough for me right now. rest is working.

Ru11
  • 871
  • 2
  • 9
  • 17

1 Answers1

0

You can use $routeParams for this. What you need to do is while defining your route for detail page add a named group argument such as

$routeProvider.when ('/details/:contactId', configObject).

When you now navigate to the details view the url that you should build should look like #/details/24.

On the details controller use the $routeParams collection to retrieve the contactId using $routeParams.contactId

Chandermani
  • 42,589
  • 12
  • 85
  • 88