码迷,mamicode.com
首页 > Web开发 > 详细

angularJs ng-switch

时间:2015-06-29 19:59:35      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:

 1 <!DOCTYPE html>
 2 <html ng-app="consoleApp">
 3 <head lang="en">
 4     <meta charset="UTF-8">
 5     <title>mytest</title>
 6 </head>
 7 <body ng-controller="appCtrl" >
 8 
 9 <input type="checkbox" ng-model="che" ng-change="change()"/>
10 
11 <div ng-switch on="eip">
12     <span ng-switch-when="checked">1</span>
13     <span ng-switch-when="add">2</span>
14     <span ng-switch-when="add1">3</span>
15 </div>
16 
17 </body>
18 
19 <script src="angular.js"></script>
20 <script>
21  var consoleApp=angular.module(consoleApp,[]);
22     consoleApp.controller(appCtrl,[$scope,function($scope){
23 
24 
25         if($scope.che===undefined){
26             $scope.eip = add1;
27         }else if($scope.che === true){
28             $scope.eip = checked;
29         }else if($scope.che === false){
30             $scope.eip=add
31         }
32 
33         $scope.change = function(){
34             if($scope.che===undefind){
35                 $scope.eip = add1;
36             }else if($scope.che === true){
37                 $scope.eip = checked;
38             }else if($scope.che === false){
39                 $scope.eip=add
40             }
41         }
42     }])
43 </script>
44 </html>

 

angularJs ng-switch

标签:

原文地址:http://www.cnblogs.com/lynnzhang/p/4608121.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!