Iam doing serverside validation in dynamicly created input fields that resides within tags. Problem is that I need to return the API error message back to my template, not set it directly in my controller. If I set it in my controller it will affect all input fields.
My plan is to do something like this:
#Template
..<span ng-show="innerNameForm.name.$error.apiResponse">{{ msg }}</span>
..<input type="text" ng-change="msg = someFunction(inputValue, innerNameForm)"...... />
#Controller
scope.someFunction = function(value, form){
apiMsg = timeout(function() {
var prom = vcRecordValidate.name(value, record_id).then(function(promise){
//If fails... do this
form.name.$setValidity('apiResponse', false);...
return promise; //THis contains the API error message
});
return prom;
}, 1000);
return apiMsg;
};
Code is just an example, and is missing some unimportant stuff..