javascript - How to bind Array from angular $scope to the input -
i have array in $scope, say
$scope.my_array = ["val_1", "val_2", "val_3"]
to bind array input element, used ng-model:
<input type="text" ng-model="my_array">
now want display array values comma separated in input box, nothing displays. possible?
in ng-repeat, iterating values, array available view.
edited: thanks, normal way working array binding. in case first using empty array:
$scope.my_array = []
then, on ng-click function, grabbing data-* attribute clicked element , pushing array:
var item = $(".some-class").data("field-type"); $scope.my_array.push(item)
iterating on working fine, not working while setting input.
look @ topic two-way filtering explained in details: how two-way filtering in angular.js? in brief should use ngmodels' $parsers , $formatters collection able make .join(", ") before setting input , make .split(/, */) before setting value model.
Comments
Post a Comment