카트 팝업 상자 감소

3854 단어


	
		
		
		<style>
			table{
				width: 600px;
			}
			table tr:nth-child(odd){
				background:lightsteelblue;
			}
			table button{
				background: blue;
			}
		</style>
		<script type="text/javascript" src="js/angular.min.js"/>
		<script>
			var app=angular.module("myapp",[]);
			app.controller("modec",function($scope){
				$scope.px='-number';
				$scope.sj=true;
				$scope.stus=[{
					ck:false,
					name:' ',
					price:12.00,
					number:2,
			
				},{
					ck:false,
					name:' ',
					price:15.00,
					number:1,
		
				},{
					ck:false,
					name:' ',
					price:15.00,
					number:1,

				}];
				// 
				$scope.add=function(){
					$scope.stus.push({
					ck:false,
					name:' ',
					price:11.00,
					number:1,
	
						
					})
				}
				// 
				$scope.delall=function(){
					for (var i=0;i<$scope.stus.length;i++) {
						if($scope.stus[i].ck==true){
							$scope.stus.splice(i,1);
							i--;
						}
					}
				}
				// / 
				$scope.ckall=function(){
					for (var i=0;i<$scope.stus.length;i++) {
						$scope.stus[i].ck=$scope.flag;
					}
				}
				// 
				$scope.del=function(index){
					$scope.stus.splice(index,1)
				}
				// 
				$scope.count=function(index,i){
					$scope.stus[i].number=$scope.stus[i].number+index;
					if($scope.stus[i].number==0){
						var f=confirm(" ?");
						if(f==true){
							$scope.stus.splice(i,1);
						}else if(f=false){
						}
						}else if($scope.stus.length == 0){
						   alter(' ');  
					}
				}
				
				
				// 
				$scope.smoney=function(){
					var smoney=0;
					for (var i=0;i<$scope.stus.length;i++) {
						smoney+=$scope.stus[i].price*$scope.stus[i].number;
					}
					return smoney;
				}
				
			})
		</script>
		
	 
	
		
        <h2> </h2><br/>
      <!--   input style="border-radius: 10px;-->
      <input style="border-radius: 10px;" ng-model="rename" placeholder=" "/>
      <select ng-model="px">
      	<option value="-number"> </option>
      	<option value="+number"> </option>
      </select>
      <button style="background: greenyellow; border-radius:6px; width: 60px;" ng-click="add()"> </button>
      <br/>
      <button style="background:red; color: #ffff;" ng-click="delall()"> </button>
      <table border="1" cellspacing="0">
      	<tr>
      		<td><input type="checkbox" ng-click="ckall()" ng-model="flag"/></td>
      		<td> </td>
      		<td> </td>
      		<td ng-click="px='number';sj=!sj"> </td>
      		<td> </td>
      		<td> </td>
      	</tr>
      	<tr ng-repeat="s in stus|orderBy:px|filter:{name:rename}">
      		<td><input type="checkbox" ng-model="s.ck"/></td>
      		<td>{{s.name}}</td>
      		<td>{{s.name}}</td>
      		<td>{{s.price|currency:"¥"}}</td>
      		<td><button ng-click="count(+1,$index)">+</button> <input style="width: 30px;" ng-model="s.number"/><button ng-click="count(-1,$index)">-</button> </td>
			<td><button ng-click="del($index)"> </button></td>
      	</tr>
      </table>
       :{{smoney()|currency:"¥"}}
	 

</code></pre> 
  <br/> 
 </div> 
</div>
                            </div>
                        </div>

좋은 웹페이지 즐겨찾기