0

Html Code

 <div ng-init="initAppliedJob()" style="padding:25px;" >
 <table class="table table-bordered table-striped">
    <thead>
        <tr>
            <th>ApplicantID</th>
            <th>Username</th>                
            <th>Edit</th>           
        </tr>
    </thead>
    <tbody>
        <tr ng-repeat="obj in initAppliedJobObj">
            <td>{{obj.ApplicantID}}</td>
            <td>{{obj.Username}}</td>        
            <td><a href="/admin/home/appliedlist/:{{obj.loginid}}">Edit</a></td>               
        </tr>
    </tbody>
 </table>
</div>

Angular Route

app.config([
'$locationProvider', '$routeProvider',
function ($locationProvider, $routeProvider) {
    $locationProvider.html5Mode({
        enabled: true,
        requireBase: false
    }).hashPrefix('!');

    $routeProvider
          .when('/admin/home/appliedlist', { 
        templateUrl: '/AngularTemplates/jobAppliedList.html',
        controller: 'JobApplyController'
    })
    .when('/admin/home/appliedlist/:userid1', { 
        templateUrl: '/AngularTemplates/jobAppliedList1.html',
        controller: 'JobApplyController'
    })
    .otherwise({   // This is when any route not matched => error
        templateUrl: '/AngularTemplates/help.html',
        controller: 'JobApplyController'
    })
}]);

Controller

 app.controller('JobApplyController', function ($scope, appliedJobService, $routeParams) {

alert($routeParams.userid1);    
$scope.initAppliedJob = function () {
    var getData = appliedJobService.initAppliedJob();
    getData.then(function (emp) { $scope.initAppliedJobObj = emp.data; },
    function (response) { document.write(response.status + "<br/>" + response.data); });
}
});

I am using angular routing when I click on Edit button my hyperlink shows like
http://localhost:1395/admin/home/appliedlist/:14

And in Controller I am getting value in alert box ":14"

Question:

1) I want value only 14 not :14 because every time I have to split that value to get original value
2) And My router goes to otherwise part that means not detect this part
.when('/admin/home/appliedlist/:userid1'

how to solve this ?

Thanks in advance.

User
  • 1,334
  • 5
  • 29
  • 61

1 Answers1

0

change

 href="/admin/home/appliedlist/:{{obj.loginid}}

to

href="#/admin/home/appliedlist/{{obj.loginid}}
harishr
  • 17,807
  • 9
  • 78
  • 125