required
入力フィールドにアスタリスクを追加するカスタマイズされたディレクティブを作成しています。これが私のリンク機能で、コメントで説明されています:
// The DOM looks like this:
// <label id="label-1" for="example-1">Name:</label>
// <input id="example-1" type="text" acc-required>
function (scope, element, attrs) {
// element would be input node
// I included jQuery, so that I can use the selector as following.
var label = $("label[for='" + element.attr('id') + "']");
if (label) {
// @ add asterisk to the label of a required input field
var abbrElement = angular.element('<abbr title="required" class="required-marker"">*</abbr>');
label.append(compile(abbrElement)(scope));
}
}
入力のid属性に基づいてラベルを選択するのは臭いですか?