Directive

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict';

angular.module('myModule').directive('formGroup', function () {
return {
restrict: 'E',
transclude: true,
templateUrl: 'core/views/directives/form-group.html',
replace: true,
scope: {
label: '@',
for: '@',
labelClass: '@',
inputClass: '@'
},
controller: ['$scope', '$element', '$attrs', function () {
}]
};
}
]);

Template

<div class="form-group">
    <label ng-if="label" for="{{for}}" class="control-label {{ labelClass }}">{{ label }}</label>

    <div ng-transclude="ng-transclude" class="ef-control {{ inputClass }}"></div>
</div>

Utilisation

<form-group for="name" label="{{ 'medias.form.name'}}" label-class="col-md-2" input-class="col-md-10">
    <input name="name" type="text" class="form-control" data-ng-model="media.name" id="name" required ng-maxlength="50">
</form-group>