This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(checkbox): support for ng-checked
Added support and demo for ng-checked usages. Fixes #1550.
- Loading branch information
1 parent
cf70325
commit 2680cf1
Showing
5 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<div ng-controller="AppCtrl" layout-padding > | ||
<p> Using ngChecked: </p> | ||
|
||
<div layout="row" layout-padding> | ||
|
||
<fieldset layout="column"> | ||
<legend>Using <md-checkbox></legend> | ||
<md-checkbox ng-repeat="item in items" ng-checked="exists(item, selected)" ng-click="toggle(item, selected)"> | ||
{{ item }} <span ng-if="exists(item, selected)">selected</span> | ||
</md-checkbox> | ||
</fieldset> | ||
|
||
<fieldset layout="column" class="standard"> | ||
<legend>Using <input type="checkbox"></legend> | ||
<div ng-repeat="item in items" class="standard" > | ||
<label> | ||
<input type="checkbox" ng-checked="exists(item, selected)" ng-click="toggle(item, selected)"/> | ||
{{ item }} | ||
</label> | ||
</div> | ||
</fieldset> | ||
|
||
</div> | ||
|
||
<div layout="column"> | ||
<md-checkbox ng-checked="selected.length >= 2" disabled>Two or more items are selected</md-checkbox> | ||
<span class="info">Selected: {{ selected }}</span> | ||
</div> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
angular.module('checkboxDemo1', ['ngMaterial']) | ||
|
||
.controller('AppCtrl', function($scope) { | ||
|
||
$scope.items = [1,2,3,4,5]; | ||
$scope.selected = []; | ||
|
||
$scope.toggle = function (item, list) { | ||
var idx = list.indexOf(item); | ||
if (idx > -1) list.splice(idx, 1); | ||
else list.push(item); | ||
}; | ||
|
||
$scope.exists = function (item, list) { | ||
return list.indexOf(item) > -1; | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.checkboxDemo1 div { | ||
clear: both; | ||
} | ||
.checkboxDemo1 md-checkbox { | ||
float: left; | ||
} | ||
|
||
legend { | ||
color : #0000ba; | ||
} | ||
|
||
p { | ||
padding-left : 10px; | ||
} | ||
|
||
.info { | ||
padding-left:13px; | ||
} | ||
|
||
div.standard { | ||
padding:10px; padding-left:15px; | ||
} | ||
|
||
fieldset.standard { | ||
margin-left:10px; | ||
} |