javascript - checked checkbox values in angularjs controller -
in application, there multiselect-dropbox. when values of checked items of multiselect dropdown list.it has,
scope.names = [1,2,4,5] means have selected 4 names list. during on change selected names other say, scope.names = [3,4]. how angularjs controller? getting following error,
typeerror: cannot read property 'indexof' of undefined @ scope.$scope.ischecked (mmmultiselect.js:85) @ $parsefunctioncall (angular.js:12332) @ object.expressioninputwatch (angular.js:12735) @ scope.$get.scope.$digest (angular.js:14217) @ scope.$get.scope.$apply (angular.js:14488) @ htmldivelement.<anonymous> (angular.js:22954) @ htmldivelement.jquery.event.dispatch (jquery.js:4409) @ htmldivelement.jquery.event.add.elemdata.handle (jquery.js:4095) #update scope.names = []; scope.onnamesselected = function() { var names = scope.names //get selected name list in array [1,2,3] scope.onnameschanged(); } scope.onnameschanged = function() { scope.names = [3,5]; //need check value in ui. }
here html options browser, checkbox when checked.
<div id="nameitem4checkbox" class="ng_checkbox" ng-class="{'ng-checkbox-hover': lihover}" ng-tool-tip="" ng-click="onclick()"> <span ng-class="{'selectedcb': ischecked(c[ngoptionid], c[ngoptionname])}" class="selectedcb"></span> </div>
when not checked.
<div id="nameitem0checkbox" class="ng_checkbox" ng-class="{'ng-checkbox-hover': lihover}" ng-tool-tip="" ng-click="onclick()"> <span ng-class="{'selectedcb': ischecked(c[ngoptionid], c[ngoptionname])}"></span> </div>
also, dont have checked fields html. selected checkbox been identified class 'csbselected'. how implement in controller.
without seeing code, looks passing in undefined controller ischecked() function. if case, check undefined/null. alternatively, may want check passing in expecting.
Comments
Post a Comment