Ich versuche, ein REST-API abfragen, die ich lokal gehostet habe und dies sollte etwas funktionieren wie folgt:ein REST-API mit einem String-Parameter abfragen Angular Ressource mit
http://localhost:51608/api/[email protected]
das funktioniert anfordern und es gibt einen Benutzer Objekt mit einer AccessLevel-Eigenschaft. Jetzt habe ich eine kantige Anwendung und möchte diese URL mit Angular Resource abfragen. Ich habe etwas wie folgt, aber die URL wird nicht korrekt erstellt.
(function() {
"use strict";
angular
.module("common.services")
.factory("userRoleResource",
["$resource",
"appSettings",
userRoleResource])
function userRoleResource($resource, appSettings) {
return $resource(appSettings.serverPath + "/api/UserRole:email", { email: '@email'});
}
})();
Ich Abfrage der oben wie folgt:
userRoleResource.query({ email: vm.userData.email },
function (data) {
vm.userData.accessLevel = data.AccessLevel;
});
Aber die Anforderung generiert wie folgt:
http://localhost:51608/api/[email protected] statt http://localhost:51608/api/UserRole?email:[email protected]
Was hier los?
Funktion userRoleResource ($ resource, appSettings) { return $ Ressource (appSettings. serverPath + "/ api/UserRole? email =: E-Mail", {E-Mail: '@email'}); } – thegio