1
Ich versuche eine Variable im Konstruktor zu setzen und benutze sie um den Pfad zum C# Controller anzugeben. Der Name der Variablen ist baseUrl.Eckige Komponente. Setze Variable im Konstruktor
angular.module('adminService', []).factory('adminService', function ($rootScope, $http, $location) {
var adminService = function() {
this.baseUrl = $location.protocol() + "://" + location.host + "/";
}
adminService.prototype.getTopics = function() {
var promise = $http(
{
method: 'POST',
url: baseUrl + '/Admin/getTopics',
contentType: 'application/json'
}).catch(function (e) {
console.log(e);
});
return promise;
}
return new adminService;
});
Was gebraucht wird, ist Ihre Frage genau? – flashjpr
Die Variable BaseUrl ist undefiniert, wenn ich versuche, sie zu verwenden. –