javascript - Radio buttons are slow to change with Angular debounce enabled -


when turn on debounce, radio buttons slow switch. half second see both buttons enabled, , old 1 clears. works ok, visually annoying.

note: found answer, i'm posting others learn.

here code

<!doctype html> <html>    <head>       <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js"></script>    </head>    <body ng-app="formexample">     <div ng-controller="examplecontroller">       <form novalidate ng-model-options="{ debounce: { default: 500 } }">           <input type="radio" ng-model="formdata.t1" value="yes" />           <input type="radio" ng-model="formdata.t1" value="no" />           <input type="radio" ng-model="formdata.t1" value="na" />       <input type="button" ng-click="reset()" value="reset" />       <input type="submit" ng-click="update(formdata)" value="save" />     </form>     <pre>form = {{formdata | json}}</pre>     <pre>master = {{master | json}}</pre>     <script>       angular.module('formexample', [])         .controller('examplecontroller', ['$scope', function($scope) {           $scope.master = {};            $scope.update = function(formdata) {             $scope.master = angular.copy(formdata);           };            $scope.reset = function() {             $scope.formdata = angular.copy($scope.master);           };            $scope.reset();         }]);     </script>    </body> </html> 

the problem forgot put name attribute on radio button set. fixes problem.

          <input type="radio" ng-model="formdata.t1" name="t1" value="yes" />           <input type="radio" ng-model="formdata.t1" name="t1" value="no" />           <input type="radio" ng-model="formdata.t1" name="t1" value="na" /> 

also validation have been screwed without name (if remove form novalidate).


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -