landers.angular
Version:
landers.angular
26 lines (25 loc) • 978 B
JavaScript
;angular.module('Landers.angular')
.directive('bool', ['Flat', function(Flat){
return {
restrict : 'AE',
require : 'ngModel',
template : function($ele, attrs){
var _class = attrs['class'] || '';
return '<span class="label label-yes ' + _class + '">Y</span><span class="label label-no ' + _class + '">N</span>'
},
link : function($scope, $ele, $attrs){
var ngModel = $attrs['ngModel'];
var $childs = $ele.children();
$scope.$watch(ngModel, function(new_value){
var bool = !!~~new_value;
if (bool) {
$childs.eq(0).show();
$childs.eq(1).hide();
} else {
$childs.eq(0).hide();
$childs.eq(1).show();
}
});
}
}
}]);