Skip to content

Commit 0fe4486

Browse files
committed
feat(ionicToggle): allow ngDisabled binding
1 parent e96a77e commit 0fe4486

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

Diff for: js/ext/angular/src/directive/ionicToggle.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ angular.module('ionic.ui.toggle', [])
1515
ngModel: '=?',
1616
ngValue: '=?',
1717
ngChecked: '=?',
18-
ngChange: '&'
18+
ngChange: '&',
19+
ngDisabled: '=?'
1920
},
2021
transclude: true,
2122
template: '<div class="item item-toggle disable-pointer-events">' +
2223
'<div ng-transclude></div>' +
2324
'<label class="toggle enable-pointer-events">' +
24-
'<input type="checkbox" ng-model="ngModel" ng-value="ngValue" ng-change="ngChange()">' +
25+
'<input type="checkbox" ng-model="ngModel" ng-value="ngValue" ng-change="ngChange()" ng-disabled="ngDisabled">' +
2526
'<div class="track disable-pointer-events">' +
2627
'<div class="handle"></div>' +
2728
'</div>' +
@@ -34,6 +35,7 @@ angular.module('ionic.ui.toggle', [])
3435
if(attr.ngChecked) input.attr('ng-checked', 'ngChecked');
3536
if(attr.ngTrueValue) input.attr('ng-true-value', attr.ngTrueValue);
3637
if(attr.ngFalseValue) input.attr('ng-false-value', attr.ngFalseValue);
38+
if(attr.ngDisabled) input.attr('ng-false-value', attr.ngFalseValue);
3739

3840
// return function link($scope, $element, $attr, ngModel) {
3941
// var el, checkbox, track, handle;
@@ -43,7 +45,7 @@ angular.module('ionic.ui.toggle', [])
4345
// track = el.children[1];
4446
// handle = track.children[0];
4547

46-
// $scope.toggle = new ionic.views.Toggle({
48+
// $scope.toggle = new ionic.views.Toggle({
4749
// el: el,
4850
// track: track,
4951
// checkbox: checkbox,

Diff for: js/ext/angular/test/toggle.html

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<html ng-app="toggleTest">
2+
<head>
3+
<meta charset="utf-8">
4+
<title>Radio</title>
5+
6+
<!-- Sets initial viewport load and disables zooming -->
7+
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
8+
<link rel="stylesheet" href="../../../../dist/css/ionic.css">
9+
<script src="../../../../dist/js/ionic.js"></script>
10+
<script src="../../../../dist/js/angular/angular.js"></script>
11+
<script src="../../../../dist/js/angular/angular-animate.js"></script>
12+
<script src="../../../../dist/js/angular/angular-sanitize.js"></script>
13+
<script src="../../../../dist/js/angular-ui/angular-ui-router.js"></script>
14+
<script src="../../../../dist/js/ionic-angular.js"></script>
15+
</head>
16+
<body>
17+
18+
<header class="bar bar-header bar-danger">
19+
<h1 class="title">Toggle</h1>
20+
</header>
21+
<content has-header="true" class="reveal-animation">
22+
<div ng-controller="TestCtrl">
23+
24+
<div class="list">
25+
<toggle ng-model="myModel" ng-disabled="isDisabled">myModel ({{!!myModel}})</toggle>
26+
<toggle ng-model="isDisabled">Disable myModel ({{!!isDisabled}})</toggle>
27+
</div>
28+
</div>
29+
</content>
30+
31+
<script>
32+
angular.module('toggleTest', ['ionic'])
33+
.controller('TestCtrl', function($scope) {});
34+
</script>
35+
</body>
36+
</html>
37+

0 commit comments

Comments
 (0)