I am very new to AngularJS and currently I am working on a form which is designed in angularjs.
My task is to validate a textbox input with a list. If the value entered in textbox is not present in the list then it should throw a validation error.
I have written the below lines of code for getting the list items through rest API:
app.factory("EatonScanningFactory", ['$http', function($http) {
var EatonScanningFactoryObj = {};
EatonScanningFactoryObj.GetToolMaxTimeList = function (columnName) {
return $http({
method: 'GET',
url: _spPageContextInfo.webAbsoluteUrl
+ "/_api/web/lists/getbytitle('Tool%20Max%20Time')/Items/"
+ "?$select=Text,Value&$orderby=Text&$filter=Title eq '" + columnName + "'",
headers: { "Accept": "application/json;odata=verbose" }
});
}
It will return the list items into an array. The below lines of code are for accessing calling the above function:
var getToolId = EatonScanningFactory.GetToolMaxTimeList('ToolNumber');
var getMaxLife = EatonScanningFactory.GetToolMaxTimeList('MaxLife');
I am unable to proceed further as I am not sure how to validate if my text box input is available in the list or not.
Please help