Working on a project where I am required to show url link and render data based on the param/id I pass in my url. In the following link AWS is the id.
link: http://link.com/Inventory/ListInventory/TID/AWS/JSON
link: http://link.com/Inventory/ListInventory/TID/param/JSON
Currently the data renders based on the id I select from the drop down but the url doesn't change. I have some code below but not sure what exactly I am doing wrong.
App:
define app
routes
$stateProvider
.state('table',
{
url: '/table',
templateUrl: './js/views/tableTmpl.html',
controller: 'tableCtrl'
})
.state('table.test',
{
url: '/test/:tid',
templateUrl: './js/views/tableTmpl.html',
controller: 'tableCtrl'
});
Controller
(function () {
var app = angular.module('inventory_app');
app.controller('tableCtrl', function($scope, tableService, uiGridConstants, $stateParams, $state) {
/************************************************
GLOBAL TEAM ID VALUES
************************************************/
$scope.tids = ['AWS', 'RET', 'DO', 'HELLO', 'HG', 'MIM', 'ALL'];
var globalteamId = 'AWS';
$scope.tidsIdFunc = function(tidId) {
globalteamId = tidId;
$scope.itemClick = function(tid){
$state.location('table.test', {'ID': tid})
};
/*Pass in argumnet for the functions below*/
getCost(globalteamId);
getAllData(globalteamId);
pieGraph(globalteamId);
histoGraph(globalteamId);
lineGraph(globalteamId);
};
View
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
TID ID
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li ng-repeat ="tid in tids">
<!-- <a ng-click="tidsIdFunc(tid)">{{tid}}</a> -->
<a ng-click="itemClick(tid)">{{tid}}</a>
</li>
</ul>
</div>
</div>
</div>
Service Making HTTP call to json
$state.location('table.test', {'ID': tid})
should look like this$state.go('table.test', {tid: tid});
at least that's what i'm using