While attempting to establish a connection with a webservice, I made an attempt using AngularJS $http option. However, when testing it out, I encountered an error in the console of my Chrome browser: ReferenceError Invalid left-hand side in assignment. Despite reviewing the code multiple times, I am unable to pinpoint where the mistake lies. Below is the script I used for testing:
<!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 have followed the "Add Some Control" example from www.angularjs.org while creating my test script. The structure of my webservice mirrors the tutorial provided by ServiceStack:
My query pertains to understanding the root cause behind the error generated within the angular.min.js file.