Skip to content

Instantly share code, notes, and snippets.

@perrygovier
Last active August 29, 2015 14:00
Show Gist options
  • Save perrygovier/11402419 to your computer and use it in GitHub Desktop.
Save perrygovier/11402419 to your computer and use it in GitHub Desktop.
.directive('ionRadio', function() {
return {
restrict: 'E',
replace: true,
require: '?ngModel',
scope: {
ngModel: '=?',
ngValue: '=?',
ngChange: '&',
icon: '@',
name: '@'
},
transclude: true,
template: '<label class="item item-radio">' +
'<input type="radio" name="{{name}}"' +
' ng-model="ngModel" ng-value="ngValue" ng-change="ngChange()">' +
'<div class="item-content disable-pointer-events" ng-transclude></div>' +
'<i class="radio-icon disable-pointer-events icon ion-checkmark"></i>' +
'</label>',
compile: function(element, attr) {
//console.log(element.children().eq(0));
console.log(attr);
if(typeof attr.name === 'undefined') element.children().eq(0).attr('name', 'radio-group');
if(attr.icon) element.children().eq(2).removeClass('ion-checkmark').addClass(attr.icon);
}
};
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment