In my path to make connection with a webservice, I tried to manage it this with AngularJS $http option. But when I try to test it, I get the next error in my chrome console: ReferenceError Invalid left-hand side in assignment. I checked the code three times but I cannot figure out what I am doing wrong. This is my testscript:
<!doctype html>
<html ng-app>
<head>
<title>Test webservice</title>
<script type="text/javascript" src="./jquery-1.9.1.js"></script>
<script type="text/javascript" src="./angular.min.js"></script>
<script type="text/javascript" src="./angular-resource-min.js"></script>
<script type="text/javascript">
function testWebservice($scope, $http) {
$scope.testService() = function() {
$http.get("http://localhost:1325/hello/world")
.success(function(data, status, headers, config) {
alert(data);
})
.error(function(data, status, headers, config) {
alert(status);
});
};
}
</script>
<head>
<body>
<div ng-controller="testWebservice">
<form ng-submit="testService()">
<input type="submit" value="test">
</form>
</div>
</body>
</html>
I used the "Add Some Control" example on www.angularjs.org for my test script. My webservice is equal to the tutorial of ServiceStack: http://www.servicestack.net/ServiceStack.Hello/
My question is, what causes the error I am getting in the angular.min.js file?
Seems like this is problematic :
$scope.testService() = function() {
may be you should try to change it like this:
$scope.testService = function() {
Change $scope.testService()
to $scope.testService
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With