angularjs ng-switch directive
Display the corresponding part according to the selected value:
<! Doctype html> <html> <head> <meta charset="utf-8"> <script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script> </head> <body ng-app=""> My favorite sites <select ng-model="myvar"> <option value="runoob">www.runoob.com <option value="google">www.google.com <option value="taobao">www.taobao.com </select> <hr> <div ng-switch="myvar"> <div ng-switch-when="runoob"> <h1>Noob Tutorial</h1> </div> <div ng-switch-when="google"> <h1>google</h1> </div> <div ng-switch-when="taobao"> <h1>Taobao</h1> </div> <div ng-switch-default> <h1>switch</h1> <p>Select different options to display corresponding values. </p> </div> </div> <hr> <p>The ng-switch directive shows or hides the corresponding part based on the current value. </p> </body> </html>
Definition and usage
The ng-switch directive shows or hides the corresponding part according to the expression.
The corresponding child element uses the ng-switch-when directive. If the match is selected and displayed,Others that match are removed.
You can set the default options by using the ng-switch-default directive,If none match,The default options are displayed.
<element ng-switch="expression"> <element ng-switch-when="value"></element> <element ng-switch-when="value"></element> <element ng-switch-when="value"></element> <element ng-switch-default></element> </element>
- More elegant multi-condition judgment writing in JS than Switch Case
- Mui js control switch state, modify the value of the switch method
- layui--js control switch method
- JS switch judgment trinocular operation while and attribute operation code
- Tutorial of using ng-if, ng-show/ng-hide and ng-switch in AngularJS
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- i want to call a child component method from a parent in vuejs
- python 3x - typeerror: 'method' object is not subscriptable
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file