Hi,
I have a model like such: {someProp: '', values: []}.
In a form for this model I would like to require that no non-empty string
values can be entered as values in my "values" property. I would require
that behavior on the values input control, not on the form submit control.
That is, form$valid is not in play.
This is what I have:
$scope.addValue = function(){
var str = $scope.newValue.trim();
if (str.length > 0) { $scope.project.values.push(str);};
$scope.newValue = '';
}
...and in my form...
<div>
<input type="text" name="new-value" ng-model="newValue" placeholder="add
value" >
<a style="cursor: pointer" ng-click="addValue()"><i
class="icon-plus-sign"></i></a>
</div>
The above pair does indeed prevent the addition of empty strings, but it
does not restore the input field to it's starting state. That is, the
placeholder value is not restored and the cursor position is not restored
to 0.
How can I accomplish this behavior?
Thanks,
Gallagher
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.