if ( attrs.bsTypeahead ) html += ' bs-typeahead="'+attrs.bsTypeahead+'"';
if ( attrs.dataItems ) html += ' data-items="'+attrs.dataItems+'"'; // for typeahead
html += '/></div>';
+ element.replaceWith(html);
+ }
+ };
+ }).
+
+ directive('myLabelInput', function() {
+ return {
+ restrict: 'C',
+ compile: function(element, attrs) {
+ var my_class = attrs['class'] || '';
+ my_class = my_class.replace(/ *my-input */,'');
+ var my_type = attrs['type'] || 'text';
+ var m = attrs.ngModel;
+ var html =
+' <div class="control-group">'+
+' <label class="control-label" for="'+m+'">'+attrs.label+'</label>'+
+' <div class="controls">'+
+' <input type="'+my_type+'" id="'+m+'" ng-model="'+m+'" placeholder="'+attrs.placeholder+'"'
+ ;
+ if ( attrs.ngRequired ) html += ' ng-required="' + attrs.ngRequired + '"';
+ html += '>'+
+' </div>'+
+' </div>';
+
element.replaceWith(html);
}
};
});
});
+ describe('my-label-input', function() {
+ it('div+label+input', function() {
+ inject(function($compile, $rootScope) {
+ var element = $compile('<div><input class="my-label-input" ng-model="m" placeholder="p" label="label"></input></div>')($rootScope);
+ expect(element.html()).toMatch(/div.*label/i);
+ });
+ });
+ });
});