Skip to content

Commit 704fe40

Browse files
committed
fix(radio): suport ng-disabled. Closes #1684
1 parent 3e6ce18 commit 704fe40

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

Diff for: js/angular/directive/radio.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ IonicModule
2525
scope: {
2626
ngModel: '=?',
2727
ngValue: '=?',
28+
ngDisabled: '=?',
2829
ngChange: '&',
2930
icon: '@',
3031
name: '@'
3132
},
3233
transclude: true,
3334
template: '<label class="item item-radio">' +
3435
'<input type="radio" name="radio-group"' +
35-
' ng-model="ngModel" ng-value="getValue()" ng-change="ngChange()">' +
36+
' ng-model="ngModel" ng-value="getValue()" ng-change="ngChange()" ng-disabled="ngDisabled">' +
3637
'<div class="item-content disable-pointer-events" ng-transclude></div>' +
3738
'<i class="radio-icon disable-pointer-events icon ion-checkmark"></i>' +
3839
'</label>',

Diff for: test/html/input-radio.html

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<html ng-app="ionicApp">
2+
<head>
3+
<meta charset="utf-8">
4+
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
5+
6+
<title>Radio Buttons</title>
7+
8+
<link rel="stylesheet" href="../../dist/css/ionic.css">
9+
<script src="../../../../dist/js/ionic.bundle.js"></script>
10+
</head>
11+
12+
<body ng-controller="MainCtrl">
13+
14+
<ion-header-bar class="bar-positive">
15+
<h1 class="title">Radio Buttons</h1>
16+
</ion-header-bar>
17+
18+
<ion-content>
19+
{{ $parent.formData }}
20+
<div class="list">
21+
22+
<ion-radio ng-model="$parent.formData.applyDisabled" ng-value="true" name="applyDisabled">Apply Disabled</ion-radio>
23+
<ion-radio ng-model="$parent.formData.applyDisabled" ng-value="false" name="applyDisabled">Enable</ion-radio>
24+
25+
<ion-radio ng-model="$parent.formData.color" ng-value="'red'" name="color" ng-disabled="$parent.formData.applyDisabled">gets disabled Red</ion-radio>
26+
<ion-radio ng-model="$parent.formData.color" ng-value="'blue'" name="color" ng-disabled="$parent.formData.applyDisabled">gets disabled Blue</ion-radio>
27+
</div>
28+
</ion-content>
29+
<script>
30+
angular.module('ionicApp', ['ionic'])
31+
.controller('MainCtrl', function($scope) {
32+
33+
});
34+
</script>
35+
</body>
36+
</html>

Diff for: test/unit/angular/directive/radio.unit.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
describe('ionRadio directive', function() {
2+
var compile, element, scope;
3+
4+
beforeEach(module('ionic'));
5+
6+
beforeEach(inject(function($compile, $rootScope, $timeout, $window) {
7+
compile = $compile;
8+
scope = $rootScope;
9+
timeout = $timeout;
10+
window = $window;
11+
ionic.Platform.setPlatform('Android');
12+
spyOn(ionic.Platform, 'ready').andCallFake(function(cb) {
13+
cb();
14+
});
15+
}));
16+
it('passes ngDisabled attribute', function() {
17+
var element = compile('<ion-radio ng-disabled="true">')(scope);
18+
el = element[0].querySelector('input');
19+
scope.$apply();
20+
expect(el.disabled)
21+
.toBe(true);
22+
});
23+
});

0 commit comments

Comments
 (0)