I'm trying to retrieve a list of users from a json generated from a url. I'm trying to adapt the code sugested on Angular UI select : Fetch data from remote service this way:
$scope.person = {};
$scope.people = {};
$http.get('https://sampleurl/pessoas/v1/?nome=' + item.name).then(
function (response) {
$scope.people = response.data;
console.log(response)
},
function () {
console.log('ERROR!!!');
}
);
However, the input just breaks, I cant even type anything ont it :(
I had to change the real url since the json contains personal data.
UPDATE i removed item.name from the url and forced a value for name. Now i can get some fixed results, but i'm failling to add them to the input:
$scope.person = {};
$scope.people = [];
//e lá vamos nós
$http.get('https://someurl/pessoas/v1/?nome=monteiro').then(
function (response) {
$scope.people = response.data;
console.log(response)
},
function () {
console.log('ERROR!!!');
}
);
getting the following error when i pick someone: Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: $item in $select.selected, Duplicate key: undefined:undefined, Duplicate value: undefined
UPDATE 2:
fixed the last error by defining all attributes from the object:
$scope.tagTransform = function (newTag) {
var item = {
nome: newTag,
email: 'unknown',
cpf: 'unknown',
matricula: 'unknown',
lotacao: 'unknown'
};
return item;
};
Now i can pick someone, but the pick box has nothing inside. Also, i still cant search for string. I tried https://sampleurl/pessoas/v1/?nome=' + item.name and https://sampleurl/pessoas/v1/?nome=' + $selected.search but none worked.