To create a controller, we need to use controller property of the state provider. To specify parameters, you can put the parameter name after the url. In the below code, you can see ‘Id’ parameter after the url and also you can see how validations are applied on these parameters using regex.
myApp.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('State1', {
url: '/SomeURL/{Id:[0-9]{4,4}}',
template: '<b>asdsd</b>',
controller: function ($scope, $stateParams) {
alert($stateParams.Id);
}
});