mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(radio): suport ng-disabled. Closes #1684
This commit is contained in:
3
js/angular/directive/radio.js
vendored
3
js/angular/directive/radio.js
vendored
@@ -25,6 +25,7 @@ IonicModule
|
||||
scope: {
|
||||
ngModel: '=?',
|
||||
ngValue: '=?',
|
||||
ngDisabled: '=?',
|
||||
ngChange: '&',
|
||||
icon: '@',
|
||||
name: '@'
|
||||
@@ -32,7 +33,7 @@ IonicModule
|
||||
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>',
|
||||
|
||||
36
test/html/input-radio.html
Normal file
36
test/html/input-radio.html
Normal file
@@ -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
test/unit/angular/directive/radio.unit.js
Normal file
23
test/unit/angular/directive/radio.unit.js
Normal file
@@ -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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user