Using the TokenInput plugin and using the built-in check of the built-in formController in AngularJS format.
I'm currently trying to check if the field contains text, and then sets the valid field, if any. The problem with using the plugin is that it creates its own input, and then ul + li.
I have access to addItem (formname) and my capabilities in the controller, I just need to set it to $ valid.
Markup.
<form class="form-horizontal add-inventory-item" name="addItem"> <input id="capabilities" name="capabilities" token-input data-ng-model="inventoryCapabilitiesAutoComplete" data-on-add="addCapability()" data-on-delete="removeCapability()" required> <div class="required" data-ng-show="addItem.capabilities.$error.required" title="Please enter capability."></div> </form>
JS.
$scope.capabilityValidation = function (capability) { if (capability.name !== "") { addItem.capabilities.$valid = true; addItem.capabilities.$error.required = false; } else { addItem.capabilities.$valid = false; addItem.capabilities.$error.required = true; } };
I run the functionValidation function when TokenInput has something injected and passing an object.
EDIT:
The ng model found at my input does things and gets autocomplete results, so I can't get ng-valid to work because it is based on the model.
$scope.inventoryCapabilitiesAutoComplete = { options: { tokenLimit: null }, source: urlHelper.getAutoComplete('capability') };
I did not write this autocomplete implementation, is there any other way to do this when I have access to the ng-model attr and move the model function somewhere else?
javascript angularjs validation
Christopher Marshall Mar 15 '13 at 16:27 2013-03-15 16:27
source share