First of all a filter is used to filter a collection and return the modified collection.
<div ng-repeat="station in stations | getById('2')">
<a class="navbar-brand" href="#">{{ stations.name }}</a>
</div>
You can then create a filter that get this value based on the Id. But that's not what you want, since you're not using an ng-repeat. You just want to get a single value out of your collection. I suggest you to create a function in your controller that does this job for you:
$scope.getStationById = function(id) {
var parsedId = +id,
foundStation;
angular.forEach($scope.stations, function(station) {
if(station.station_id === parsedId) {
foundStation = station;
}
});
return foundStation;
};
jsFiddle
or you can use the currentstation scope variable:
jsFiddle - update
Edit: Maybe I'm wrong, if you want to show more than just the name, it's a good advice to avoid multiple iterations on the controller. With a filter you can limit this to one iteration. Your filter should give back a new collection with only one result:
app.filter('getById', function() {
return function(coll, id) {
var parsedId = +id,
foundStation;
angular.forEach(coll, function(station) {
if(station.station_id === parsedId) {
foundStation = station;
}
});
// Create array if station found otherwise return empty array
return foundStation ? [foundStation] : [];
};
});
JsFiddle