I want to get the id from the url http: // localhost / Inventory / Details / 4b72c58e-ec01-4cc7-aa84-0763d9f9aad2 in the controller. I use $ stateProvider, but $ stateParams.id is always empty. Here is my module:
'use strict'; (function (angular) { angular.module('inventory', [ 'ngMaterial', 'common', 'ui.router' ]).config(configuration); configuration.$inject = ['$stateProvider']; function configuration($stateProvider) { $stateProvider .state('inventory.details', { url: '/Inventory/Details/:id', templateUrl: '/app/inventory/inventory.html', controller: 'InventoryController' }); } }(angular)); Here is the controller:
(function() { 'use strict'; angular.module('inventory').controller('InventoryController', InventoryController); InventoryController.$inject = ['$stateParams']; function InventoryController($stateParams) { var id = $stateParams.id; UPD The problem was in the controller declaration:
<div ng-include="'/app/inventory/inventory.html'" ng-controller="InventoryController as vm"></div> After replacing with:
<div ui-view="page"></div> everything is working