Skip to content

Commit

Permalink
fix(demo): updated demo for switcher component
Browse files Browse the repository at this point in the history
  • Loading branch information
lugovsky committed Jun 7, 2016
1 parent 85181fd commit 6c4f1b6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
24 changes: 24 additions & 0 deletions src/app/pages/form/inputs/widgets/switch/SwitchPanelCtrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @author v.lugovsky
* created on 07.06.2016
*/
(function () {
'use strict';

angular.module('BlurAdmin.pages.form')
.controller('SwitchPanelCtrl', SwitchPanelCtrl);

/** @ngInject */
function SwitchPanelCtrl() {
var vm = this;

vm.switcherValues = {
primary: true,
warning: true,
danger: true,
info: true,
success: true
};
}

})();
5 changes: 3 additions & 2 deletions src/app/pages/form/inputs/widgets/switch/switch.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
scope: {
ngModel: '='
},
template: '<div class="switch-container {{color}}"><input type="checkbox" ng-model="ngModel"></div>',
template: function(el, attrs) {
return '<div class="switch-container ' + (attrs.color || '') + '"><input type="checkbox" ng-model="ngModel"></div>';
},
link: function (scope, elem, attr) {
$timeout(function(){
scope.color = attr.color;
var input = $(elem).find('input');
input.bootstrapSwitch({
size: 'small',
Expand Down
12 changes: 6 additions & 6 deletions src/app/pages/form/inputs/widgets/switch/switch.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div ng-init="switches = [ true, true, true, true, true, true ]" class="switches clearfix">
<switch color="primary" ng-model="switches[5]"></switch>
<switch color="warning" ng-model="switches[1]"></switch>
<switch color="danger" ng-model="switches[2]"></switch>
<switch color="info" ng-model="switches[3]"></switch>
<switch color="success" ng-model="switches[0]"></switch>
<div ng-controller="SwitchPanelCtrl as switchPanelVm" class="switches clearfix">
<switch color="primary" ng-model="switchPanelVm.switcherValues.primary"></switch>
<switch color="warning" ng-model="switchPanelVm.switcherValues.warning"></switch>
<switch color="danger" ng-model="switchPanelVm.switcherValues.danger"></switch>
<switch color="info" ng-model="switchPanelVm.switcherValues.info"></switch>
<switch color="success" ng-model="switchPanelVm.switcherValues.success"></switch>
</div>

0 comments on commit 6c4f1b6

Please sign in to comment.