Add radiobutton directive

This commit is contained in:
Jan Skovgaard
2019-02-27 09:55:52 +01:00
parent afc872de5a
commit 3643e170c5
2 changed files with 65 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
/**
@ngdoc directive
@name umbraco.directives.directive:umbRadiobutton
@restrict E
@scope
@description
<b>Added in Umbraco version 7.14.0</b> Use this directive to render an umbraco radio button.
<h3>Markup example</h3>
<pre>
<div ng-controller="My.Controller as vm">
<umb-radiobutton
name="checkboxlist"
value="{{key}}"
model="true"
text="{{text}}">
</umb-radiobutton>
</div>
</pre>
@param {boolean} model Set to <code>true</code> or <code>false</code> to set the radiobutton to checked or unchecked.
@param {string} value Set the value of the radiobutton.
@param {string} name Set the name of the radiobutton.
@param {string} text Set the text for the radiobutton label.
**/
(function () {
'use strict';
function RadiobuttonDirective() {
var directive = {
restrict: 'E',
replace: true,
templateUrl: 'views/components/forms/umb-radiobutton.html',
scope: {
model: "=",
value: "@",
name: "@",
text: "@"
}
};
return directive;
}
angular.module('umbraco.directives').directive('umbRadiobutton', RadiobuttonDirective);
})();

View File

@@ -0,0 +1,11 @@
<label class="radio umb-form-control umb-form-control--radiobutton">
<input type="radio" name="radiobuttons-{{name}}"
value="{{value}}"
ng-model="model"
class="umb-form-control__input" />
<div class="umb-form-control__state umb-form-control__state" aria-hidden="true">
<div class="umb-form-control__check"></div>
</div>
<span class="umb-form-control__text">{{text}}</span>
</label>