AngularJS directive for the bootstrap-switch jQuery plugin.
##Usage
###Installation
$ bower install angular-bootstrap-switch
This will install AngularJS, jQuery, and the original bootstrap-switch.
###Directive The directive can work on both element and attribute levels. The following example contains all of the supported attributes:
<input
bs-switch
ng-model="isSelected"
type="checkbox"
switch-active="{{ isActive }}"
switch-size="{{ size }}"
switch-animate="{{ animate }}"
switch-label="{{ label }}"
switch-icon="{{ icon }}"
switch-on-label="{{ onLabel }}"
switch-off-label="{{ offLabel }}"
switch-on="{{ on }}"
switch-off="{{ off }}" >
Short doc for all of the attributes:
ng-model
, the value to bind the switch totype
, can bechechbox
(default) orradio
. This value must be a string, as it cannot be changed once set (see this answer on StackOverflow).switch-active
, determines if the switch is enabled or notswitch-size
, can be the empty string as default,mini
,small
,large
switch-animate
, determines if the switch animates when toggledswitch-label
, sets the toggle labelswitch-icon
, sets the toggle icon (e.g.icon-save
)switch-on-label
, sets the positive (checked) textswitch-off-label
, sets the negative (unchecked) textswitch-on
, sets the positive (checked) class, can beprimary
(as default),default
,info
,success
,warning
,danger
switch-off
, sets the positive (checked) class, can bedefault
(as default),primary
,info
,success
,warning
,danger
###Examples
The example
folder shows a simple working demo of the switch.
##Development
###Test and build
To build the directive yourself you need to have NodeJS. Then do the following:
$ npm install -g grunt-cli bower karma
$ npm install
$ bower install
$ grunt test-travis
$ grunt build
###Contribute
To contribute, please follow the generic AngularJS Contributing Guidelines, with the only exception to send the PR to the develop
branch instead of master
.
##Author
Francesco Pontillo (mailto:[email protected])
##License
Copyright 2013 Francesco Pontillo
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.