Question: I have this crud URL format:

> 
> domain.com/config/someconfig/edit/2
> 
> 
> 

Where I open the form ready to be prepped with the contents from record of id 2.

**How**, can I just get the 2 from the URI?

The easiest way possible would be something like:

```
if($location._uriseg(4) && typeof $location._uriseg(4) === 'number') then...

```

Is angular.js missing something like this?

Answer: 
Created a filter for angular to have that method (\_uriseg) available:

```
app.filter('_uriseg', function($location) {
  return function(segment) {
    // Get URI and remove the domain base url global var
    var query = $location.absUrl().replace(BASE_URL,"");
    // To obj
    var data = query.split("/");    
    // Return segment *segments are 1,2,3 keys are 0,1,2
    if(data[segment-1]) {
      return data[segment-1];
    }
    return false;
  }
});

```

Now I'm able to call:

```
$scope.email = $filter('_uriseg')(3);

```

So using this filter one can fetch the value of any URL segment.

I still believe angular.js to have something similar, if anyone care to share the default method, thanks.

---

I have also created another filter to help codeigniter fellows out there, to get controller actions from the URI, codeigniter style:

```
app.filter('getCImr', function($location) {
  return function(controller) {
    // Get URI and remove the domain base url global var
    var query = $location.absUrl().replace(BASE_URL,"");
    // To obj
    var data = query.split("/");
    // Remove CI controller
    delete data[0];    
    var result = {};
    // Map action and record ID/Whatever
    result[data[1]] = data[2];
    return result;
  }
});

```

So let's say your codeigniter URI is something like:

> 
> domain.com/controller/function/id
> 
> 
> 

You can do a:

```
$scope.id = $filter('getCImr')('controller')['function'];

```

To get:

```
console.log($scope.id); // id

```

Thanks anyway.
My version the codeigniter way..

```
angular.module('myApp.Filters', [])
.filter('uri', function($location) {
    return {
        segment: function(segment) {
            var data = $location.path().split("/");
            if(data[segment-1]) { return data[segment-1]; }
            return false;
        },
        total_segments: function() {
            var data = $location.path().split("/");
            var i = 0;
            angular.forEach(data, function(value){
            if(value.length) { i++; }
            });
            return i;
        }
    };
});

//GET URI SEGMENT
$filter('uri').segment(0)
//GET SEGMENT LENGTH
$filter('uri').total_segments()

```