Within my HTML, I have a structure that looks like {{ i.userId | userName }}. Essentially, I am attempting to convert this into a name by utilizing a filter. However, I am encountering numerous challenges with the asynchronous function required to retrieve the data.
app.filter('userName', function($http) {
return function(value) {
if (!value) return '';
var user;
$http({
method: 'GET',
url: 'http://localhost:3000/api/Users?filter={"where":{"id":' + value + '}}'
}).success(function(response) {
user = response;
});
return user.name;
}
});
I attempted to organize it in a callback format, but unfortunately, I was unable to make it function correctly.