Sikandar Sahab
Sikandar Sahab

Reputation: 708

How do I make hyperlink move to next page taking angularjs variable with it?

I have a table row being populated with the array of Json objects.

I actually want to click one of the row item and move to the next page by also taking the clicked item's id.

My Code:

  1. AngularJS function

            $scope.findAllCompanies = function() {
    
            $http.get('http://blahblablah/company/all').
    
            then(function(response) {
                $scope.companyList = response.data;
            });
    
        }
    
  2. HTML: traversing the companyList

        <tr data-ng-repeat="company in companyList"> 
    
        <td> <a href="/pages/company"> {{company.companyId}} </a>  </td>
        <td> {{company.legalName}} </td>
        <td> {{company.dbaName}} </td>
        <td> {{company.formation}} </td>
    
    </tr>
    

So now, If I click on companyId in any row, the page should be redirected to company.html?companyId=anyNum

I am thinking to merge them here, something like this: enter image description here

Thanks, and looking forward to hear from you.

Upvotes: 0

Views: 18

Answers (1)

jitender
jitender

Reputation: 10429

Using ng-href

<a ng-href="/pages/company?companyId={{company.companyId}}"> {{company.companyId}} </a>

Upvotes: 1

Related Questions