kumara
kumara

Reputation: 937

angular route params not working

i need to passe id using $routeParam. my code is like below

js file

var app = angular.module("myApp");

app.controller("quotationPendingController", function ($scope,$http,NgTableParams,$filter,$timeout,$rootScope,ModalService,$window){

$scope.loadQuotationDetailsOnQuotationForUpdate =  function (quotation) {

$window.location.href = ('quotation_approve.jsp#/?target='+quotation.quotationId+'&action=u');
}

});
jsp file like below 

> Blockquote

<a class="grid-btn row-edit" target="_blank" data-toggle="tooltip" data-placement="top" title="" data-original-title="Edit"  ng-click="loadQuotationDetailsOnQuotationForUpdate(quotation)"><span class="glyphicon glyphicon-pencil"></span></a> 

i need to change loadQuotationDetailsOnQuotationForUpdate(quotation) function from $routeParam.

how i change below function

$scope.loadQuotationDetailsOnQuotationForUpdate =  function (quotation) {

$window.location.href = ('quotation_approve.jsp#/?target='+quotation.quotationId+'&action=u');
}

Upvotes: 0

Views: 95

Answers (1)

jeremy-denis
jeremy-denis

Reputation: 6878

In Angular we can advise you to use a true router component to manage your navigation. For sample with ui-router (https://ui-router.github.io/ng1/) something like :

1) you can define a specific state for your jsp

$stateProvider
 .state('quotation_approve', {
 url: '/quotation_approve.jsp/:target/:action',
 templateUrl: 'quotation_approve.jsp',
 controller : "your template controller"
})

2) then you will be abble to change the function to navigagte to your page

Don't forget then inject $state service to your controller

$scope.loadQuotationDetailsOnQuotationForUpdate =  function (quotation) {
   $state.go('quotation_approve',{ "target": quotation.quotationId,"action":"u"});
}

Upvotes: 1

Related Questions