angularjs - Angular: How to uncheck all checkboxes with a link? -


This is my problem:

I uncheck a checkbox and reset the values ​​of a radius Trying to do a variable with a link, though, it does not seem to work, can anyone help?

javascript:

  var app = angular Module ('myApp', []); App.controller ('indexctrl', ['$ scope', function ($ scope) {$ scope.colors = [{id: 1, name: "blue"}, {id: 2, name: "green"}, {Id: 3, name: "red"}] $ scope.color_ids = []; $ scope.clearAll = function () {angular.forEach ($ scope.color_ids, function (color_id) {color_id.checked = false; / / Anything does not work !! color_id.selected = false; //}); $ scope.color_ids = []; $ scope.color_ids.selected = false; // either does not work;}}));   

HTML

  & lt; Div ng-controller = "indexCtrl" & gt; {{1 + 1}} & lt; H2 & gt; Product & lt; / H2 & gt; & Lt; Div class = "filter two-two" & gt; & Lt; A ng-click = "clear (all)" & gt; Clear all filters & lt; / A & gt; & Lt; H3 & gt; Color & lt; / H3 & gt; & Lt; Div ng-repeat = "color in colors" & gt; {{Color.name}} & lt; Input type = "checkbox" ng-model = "color_id" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;    

You do not add anything to the color_id array, so foreach is nothing.

I have updated your code only to use the main color array and add "selected" property to it:

html:

  {{color.name}} & lt; Input type = "checkbox" ng-model = "color.selected" & gt;   

Javascript:

  Angular ForEach ($ scope.colors, function (color_id) {color_id.selected = false;});    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -