};
}).
- directive('myLabelInput', function() {
+directive('myLabelInput', function() {
return {
restrict: 'C',
compile: function(element, attrs) {
element.replaceWith(html);
}
};
- })
+})
+
+.directive('myLabelSelect', function() {
+ return {
+ restrict: 'C',
+ compile: function(element, attrs) {
+ var my_class = attrs['class'] || '';
+ my_class = my_class.replace(/ *my-input */,'');
+ var m = attrs.ngModel;
+ var html =
+' <div class="control-group">'+
+' <label class="control-label" for="'+m+'">'+attrs.label+'</label>'+
+' <div class="controls">'+
+' <select id="'+m+'" ng-model="'+m+'"';
+ ;
+ if ( attrs.ngOptions ) html += ' ng-options="' + attrs.ngOptions + '"';
+ html += '></select>'+
+' </div>'+
+' </div>';
+
+ element.replaceWith(html);
+ }
+ };
+})
+
.directive('bsTypeahead', ['$parse', function($parse) {
'use strict';
});
});
});
+
+ describe('my-label-select', function() {
+ beforeEach(module('myApp.services'));
+ it('div+label+input', function() {
+ inject(function($compile, $rootScope, RegistrationState) {
+ dump( RegistrationState() );
+ var element = $compile('<div><select class="my-label-select" ng-model="m" label="label" ng-options="value for value in RegistrationState()"></select></div>')($rootScope);
+ dump(element.html());
+ expect(element.html()).toMatch(/div.*label.*label.*div.*select.*select.*div.*div/i);
+ });
+ });
+ });
+
});