I am still learning AngularJS and attempting to retrieve user input from a text box to use for querying an endpoint and displaying the result in another text box. Here is a preview of the user interface:
https://i.sstatic.net/zXCgQ.jpg
Here is the HTML code for the UI:
<div hidden id="userData">
<label style="font-size: medium">Enter Input *</label>
<input name="userData" class="form-control" ng-model="request.userData">
<div ng-message="required">This field is required</div>
</div>
<div class="row form-group">
<button type="button" class='btn btn-success' ng-click="queryData()">Query</button>
</div>
<input name="userName" class="form-control" ng-model="request.userName">
<div ng-message="required">This field is required</div>
</div>
Within the Controller, I am working on retrieving the user input (userData) to use in an Odata endpoint as a query parameter:
$scope.queryData = function () {
var sList = getAppData.getCData(`STR?Bar eq '${$scope.request.userData}'`, `Basic ${$scope.key}`)
........
};
However, the above code is not returning any data to sList. Therefore, I attempted to store the user input in a variable and use it in the query:
$scope.queryData = function () {
var userEntered = ${$scope.request.userData };
var strainsList = getAppData.getCData(`STR?Bar eq '`+userEntered+`'`, `Basic ${$scope.key}`)
........
};
Unfortunately, this method did not work during debugging. I found that hardcoding the input, as shown below, does work:
var sList = getAppData.getCData(`STR?Bar eq '1234'`, `Basic ${$scope.key}`)
Can anyone provide insight on how to successfully retrieve user input for the Button function?