Currently, I am facing an issue with my web page where I use the ng-repeat
directive to populate a table with a list of companies. My goal is to have a functionality where clicking on a table row opens another page with a form to edit the selected company.
Here is a snippet of the html
code for the page:
<table>
<tr>
<th>Name</th>
<th>Address</th>
</tr>
<tr ng-repeat="company in companies">
<td>{{company.companyName}}</td>
<td>{{company.companyAddress}}</td>
</tr>
</table>
Below is the controller responsible for handling the click event:
angular.module('companyApp.companyForm', ['ngRoute', 'ngResource'])
.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/updateCompany/:companyId', {
templateUrl: 'app/companyForm/companyForm.html',
controller: 'UpdatedCompanyController'
});
}])
.controller('UpdatedCompanyController', ['$scope', '$resource',
function ($scope, $resource) {
}]);
Despite my efforts, my attempts to redirect to a new page upon clicking on a table row have not been successful. I have tried using:
$location.url("#/updateCompany").search({id:company.id})
However, this only generates a URL without any actual redirection. I also attempted:
window.location.href = //...
But once again, I find myself redirected back to the default page upon clicking on a table item. Can anyone provide guidance on how I can successfully redirect to a new page upon clicking on a table row?