Skip to content

Commit

Permalink
fix(radio): suport ng-disabled. Closes #1684
Browse files Browse the repository at this point in the history
  • Loading branch information
perrygovier committed Jun 27, 2014
1 parent 3e6ce18 commit 704fe40
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
3 changes: 2 additions & 1 deletion js/angular/directive/radio.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ IonicModule
scope: {
ngModel: '=?',
ngValue: '=?',
ngDisabled: '=?',
ngChange: '&',
icon: '@',
name: '@'
},
transclude: true,
template: '<label class="item item-radio">' +
'<input type="radio" name="radio-group"' +
' ng-model="ngModel" ng-value="getValue()" ng-change="ngChange()">' +
' ng-model="ngModel" ng-value="getValue()" ng-change="ngChange()" ng-disabled="ngDisabled">' +
'<div class="item-content disable-pointer-events" ng-transclude></div>' +
'<i class="radio-icon disable-pointer-events icon ion-checkmark"></i>' +
'</label>',
Expand Down
36 changes: 36 additions & 0 deletions test/html/input-radio.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<html ng-app="ionicApp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">

<title>Radio Buttons</title>

<link rel="stylesheet" href="../../dist/css/ionic.css">
<script src="../../../../dist/js/ionic.bundle.js"></script>
</head>

<body ng-controller="MainCtrl">

<ion-header-bar class="bar-positive">
<h1 class="title">Radio Buttons</h1>
</ion-header-bar>

<ion-content>
{{ $parent.formData }}
<div class="list">

<ion-radio ng-model="$parent.formData.applyDisabled" ng-value="true" name="applyDisabled">Apply Disabled</ion-radio>
<ion-radio ng-model="$parent.formData.applyDisabled" ng-value="false" name="applyDisabled">Enable</ion-radio>

<ion-radio ng-model="$parent.formData.color" ng-value="'red'" name="color" ng-disabled="$parent.formData.applyDisabled">gets disabled Red</ion-radio>
<ion-radio ng-model="$parent.formData.color" ng-value="'blue'" name="color" ng-disabled="$parent.formData.applyDisabled">gets disabled Blue</ion-radio>
</div>
</ion-content>
<script>
angular.module('ionicApp', ['ionic'])
.controller('MainCtrl', function($scope) {

});
</script>
</body>
</html>
23 changes: 23 additions & 0 deletions test/unit/angular/directive/radio.unit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
describe('ionRadio directive', function() {
var compile, element, scope;

beforeEach(module('ionic'));

beforeEach(inject(function($compile, $rootScope, $timeout, $window) {
compile = $compile;
scope = $rootScope;
timeout = $timeout;
window = $window;
ionic.Platform.setPlatform('Android');
spyOn(ionic.Platform, 'ready').andCallFake(function(cb) {
cb();
});
}));
it('passes ngDisabled attribute', function() {
var element = compile('<ion-radio ng-disabled="true">')(scope);
el = element[0].querySelector('input');
scope.$apply();
expect(el.disabled)
.toBe(true);
});
});

0 comments on commit 704fe40

Please sign in to comment.