Coder Social home page Coder Social logo

zwq8299174 / angular-sku Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amibug/angular-sku

1.0 2.0 0.0 220 KB

angular sku siwtch Demo

Home Page: http://codepen.io/hzxs1990225/pen/VYyOdW

License: MIT License

CSS 9.83% HTML 13.98% JavaScript 76.19%

angular-sku's Introduction

angular-sku

demo:http://codepen.io/hzxs1990225/pen/VYyOdW

专栏:http://html-js.com/article/2734/

In your web page:

<div ui-sku split-str="#" init-sku="M#红色#男" sku-data="skuInfo" on-ok="callback($event)">
 <div class="row f-cb">
   <div class="l-col">尺码</div>
   <div class="r-col">
     <ul class="m-sku f-cb">
       <li><span ng-class="{'js-seleted': keyMap['S'].selected, 'js-disabled': keyMap['S'].disabled}" ng-click="onSelect('S')">S</span></li>
       <li><span ng-class="{'js-seleted': keyMap['M'].selected, 'js-disabled': keyMap['M'].disabled}" ng-click="onSelect('M')">M</span></li>
       ...
     </ul>
   </div>
   ...
 </div>
</div>

<script src="angular.js"></script>
<script src="dist/angular-sku.min.js"></script>
<script>
var myapp = angular.module('skuApp', ['ui.angularSku']);

myapp.controller('skuController', function ($scope) {
  'use strict';
  $scope.type = 'parent';
  $scope.callback = function(count){
    $scope.count = count;
  }
  $scope.skuInfo = {

    'S#红色#男': {
      count: 0
    },
    'S#红色#女': {
      count: 0
    },
    ...
  }
});

组件接收4个参数skuData,splitStr,initSku,onOk

  • skuData为组件结接收的数据(数据有一定格式,需要后台开发配合给)

       {
          'S#红色#男': {
            count: 0
          },
          'M#红色#女': {
            count: 0
          },
          'S#橙色#男': {
            count: 1
          },
         'M#橙色#女': {
            count: 1
          },
          .....
        }
    
  • splitStr为不同key之间的分格缝(S#红色#男中指的是‘#’)

  • initSku为默认设置的选中key(可以设置为M#红色#女)

  • onOk点击key之后的callback(callback接受的参数为选择sku组合(例如'S#橙色#男')对应的值)

@support IE>=8

angular-sku's People

Contributors

amibug avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.