C
C#2mo ago
veronicas

Not a function? Service

Hey guys , I've gotten an error and I don't know why. I triple checked my variables but still getting an error.

app.service("MachineProblemService",function ($http) {
this.staticConnect = function (userEmail, userName) {
return $http({
method: "POST",
url: "/Home/StaticFunction",
params: {
UEmail: userEmail,
UName: userName
}
});
};
});

app.controller("MachineProblemController", function ($scope, RegistrationApplicationService) {
$scope.connectStatic = function () {
var postData = MachineProblemService.staticConnect($scope.uEmail, $scope.uName);
postData.then(function (ReturnedData) {
var returnedValue = Number(ReturnedData.data);
if (returnedValue == 1) {
alert("test")
}
else {
alert("help")
}
});
}

app.service("MachineProblemService",function ($http) {
this.staticConnect = function (userEmail, userName) {
return $http({
method: "POST",
url: "/Home/StaticFunction",
params: {
UEmail: userEmail,
UName: userName
}
});
};
});

app.controller("MachineProblemController", function ($scope, RegistrationApplicationService) {
$scope.connectStatic = function () {
var postData = MachineProblemService.staticConnect($scope.uEmail, $scope.uName);
postData.then(function (ReturnedData) {
var returnedValue = Number(ReturnedData.data);
if (returnedValue == 1) {
alert("test")
}
else {
alert("help")
}
});
}
this is the error im getting: TypeError: MachineProblemService.staticConnect is not a function at $scope.connectStatic (Controller.js:22:46) at fn (eval at compile (angular.js:16548:15), <anonymous>:4:159) at e (angular.js:29123:13) at b.$eval (angular.js:19523:16) at b.$apply (angular.js:19622:20) at HTMLAnchorElement.<anonymous> (angular.js:29127:13) at HTMLAnchorElement.dispatch (jquery-3.7.0.min.js:2:39997) at ce.event.add.v.handle (jquery-3.7.0.min.js:2:37968)
1 Reply
Pobiega
Pobiega2mo ago
This isnt a C# question. This is a ja/angular question.
Want results from more Discord servers?
Add your server