Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                .container(ng-app='myApp', ng-controller='MainCtrl')
  h1 angular multi checkbox
  multi-check.my-check(ng-model='selectedThings')
    multi-check-item(ng-repeat='thing in things', value='{{thing._id}}', title='{{thing._id}}') {{thing.name}}
  br
  multi-check.my-check(ng-model='selectedThings')
    multi-check-item(ng-repeat='thing in things', value='{{thing._id}}', title='{{thing._id}}') {{thing.name}}
  h2 model: {{selectedThings}}
              
            
!

CSS

              
                .container
  width 90%
  max-width 900px
  margin 0 auto
  font-family sans-serif

.my-check ng-transclude
  display flex
  flex-flow row wrap
  ng-transclude
    display block
  .check-item
    flex-basis 20%
    position relative
    @media (max-width:1060px)
      flex-basis 33%
    @media (max-width:720px)
      flex-basis 50%
    @media (max-width:520px)
      flex-basis 100%
    label
      padding 1rem
      display flex
      justify-content space-around
      box-shadow inset -2px -2px 20px rgba(0,0,0,0.15)
      transition background 0.16s
    input[type='checkbox']
      position absolute
      top 0
      left 0
      width 100%
      height 100%
      z-index 100
      opacity 0
      cursor pointer
    input[type='checkbox']:hover ~ label
      background darken(white, 10%)
    input:checked ~ label
      background slategrey
      span:before
        content '✔'
        position absolute
        left 1rem
    input:checked:hover ~ label
      background darken(slategrey, 10%)
              
            
!

JS

              
                angular.module 'myApp', ['multi-check']
.controller 'MainCtrl', ($scope) ->
  $scope.things = [
    {_id:'123',name:'Maggie'}
    {_id:'124',name:'Lewis'}
    {_id:125, name:'Barry'}
    {_id:126, name:'Jeff'}
    {_id:127, name:'Brad'}
    {_id:128, name:'Vindny'}
  ]
  $scope.selectedThings = [123, '127']
  
# https://github.com/ndxbxrme/angular-multi-check
  
angular.module 'multi-check', []
.directive 'multiCheck', ->
  restrict: 'EA'
  require: 'ngModel'
  transclude: true
  replace: true
  scope: 
    ngModel: '='
  template: '<div class="multi-check"><ng-transclude></ng-transclude></div>'
  link: (scope, elem, attrs, ngModel) ->
    scope.$watch 'ngModel', (val) ->
      if not val
        val = []
      if not angular.isArray val
        val = [val + '']
      scope.model = val
      ngModel.$setPristine()
      return
    , true
    scope.updateModel = (id, value) ->
      if not value
        if scope.model.indexOf(id) isnt -1
          scope.model.splice scope.model.indexOf(id), 1
        else
          scope.model.splice scope.model.indexOf(parseInt(id)), 1
      else
        scope.model.push id
      ngModel.$setViewValue(scope.model)
      ngModel.$setDirty()
      return
.directive 'multiCheckItem', ->
  restrict: 'EA'
  transclude: true
  replace: true
  template: '<div class="check-item"><input type="checkbox" id="{{id}}" ng-model="value" ng-change="change()" ><label for="{{id}}"><ng-transclude></ng-transclude></label></div>'
  link: (scope, elem, attrs) ->
    scope.id = 'ndxcbi' + attrs.value
    scope.$watch ->
      scope.$parent.$parent.model
    , (n) ->
      if n
        scope.value = n.indexOf(attrs.value) isnt -1 or n.indexOf(parseInt(attrs.value)) isnt -1
    , true
    scope.change = ->
      scope.$parent.$parent.updateModel attrs.value, scope.value
              
            
!
999px

Console