HLJ 发布于
2018-08-15 16:48:23

AngularJS ng-switch指令与示例

AngularJS ng-switch指令与示例

html代码:
<body ng-app="AngularswitchApp">
  <div ng-controller="ngswitchctrl">
    Select Item: 
    <select ng-model="selectval" ng-options="item for item in items"></select>
    <div ng-switch ="selectval">
    <div ng-switch-when="one"><b>DIV1</b>: You Selected value one</div>
    <div ng-switch-when="two"><b>DIV2</b>: You Selected value two</div>
    <div ng-switch-when="three"><b>DIV3</b>: You Selected value three</div>
    <div ng-switch-default>You are in default switch case.</div>
    </div>
  </div>
</body>
JavaScript代码:
<script>
var app = angular.module("AngularswitchApp", []);
app.controller("ngswitchctrl", function ($scope) {
  $scope.items = ['one', 'two', 'three', 'four'];
  $scope.selectval = "one";
});
</script>
当前文章内容为原创转载请注明出处:http://www.good1230.com/detail/2018-08-15/100.html
最后生成于 2023-06-18 18:29:58
此内容有帮助 ?
0