Come rendere angularjs $ resource restituisce un array di oggetti derivati / prototipati da un oggetto dominio specificato?
Ecco un esempio su http://plnkr.co/edit/AVLQItPIfoLwsgDzoBdK?p=preview che elabora un set di oggetti Note
s.
app.controller('MainCtrl', function($scope, NoteResource) {
$scope.name = 'World';
$scope.notes = NoteResource.query();
$scope.spellCheckAllNotes = function() {
angular.forEach($scope.notes, function(note) {
note.spellCheck();
});
}
});
Il problema è che i rendimenti $ risorsa gamma di Resource
s e non una serie di Note
s con Resource
metodi aggiunti ai prototipi.
[soluzione deve seguire "buona" javascript pratiche]
un follow-up: http://stackoverflow.com/questions/23528451 dati – okigan