javascript - angular-tags: Reset the tags input value -
index.html
<div class="modal-header" > <button type="button" class="close" ng-click = "submit(information.add, information.subject, information.emailcontent); close()">×</button> <h3>compose email</h3> </div> <div class="modal-body"> <form name = "form.email"> <tags options="{addable: true}" typeahead-options="typeaheadopts" data-model="information.add" data-src="toperson toperson toperson in to"></tags> <input type="text" placeholder="subject" style="width:95%;" data-ng-model = "information.subject"><br /> <textarea style="width:95%;" rows="10" data-ng-model = "information.emailcontent"></textarea> </form> </div> emailviewcontroller.js
$scope.information = { add: [], subject: [], emailcontent: [] }; $scope.clear = function() { if ($scope.information.add !== "") { $scope.information = null; } }; i setting value of $scope.information null. after doing this, input box value bound information.subject , textarea value bound information.emailcontent reset. however, tags input value bound information.add not reset. know why being caused.
i think $scope.remove() in angular-tags widget should used remove tag. not sure how implement though. angular-tags source code can found here - https://github.com/boneskull/angular-tags/blob/master/src/tags.js
here plunker - http://plnkr.co/edit/pag1k5n37btoflobnn7k?p=preview
attempt 1
this plunker of have tried far - http://plnkr.co/edit/jje2bu8zkkyw36rtayml?p=preview . redefining value of $scope.info null in function wrapped inside $timeout. thought maybe changes made $scope not being applied view, tried wrap in $timeout. doing did not fix problem though.
this code $scope.information = null; supposed nuke information , clear entire thing? sets reference object containing arrays null. arrays still there , still referenced widget expect - (i'm not sure how library using tags implemented)
the below code empties arrays:
$scope.information.add.length = 0; $scope.information.subject.length = 0; $scope.information.emailcontent.length = 0;
Comments
Post a Comment