ng-switch指令

来源:互联网 发布:北京赛车pk10程序源码 编辑:程序博客网 时间:2024/06/07 06:24
<!DOCTYPE html><html ng-app="switchExample"><head>    <meta charset="UTF-8">    <title></title>    <script src="../js/angular.js"></script>    <script>        angular.module('switchExample', [])                .controller('ExampleController', ['$scope', function($scope) {                    $scope.items = ['dog', 'cat', 'other'];                    $scope.selection = $scope.items[0];                }]);    </script></head><body><div ng-controller="ExampleController">        <select ng-model="selection" ng-options="item for item in items"></select>    <div ng-switch="selection">        <span ng-switch-when="dog">choose dog.</span>        <span ng-switch-when="cat">choose cat.</span>        <span ng-switch-default>choose other.</span>    </div></div></body></html>

0 0
原创粉丝点击