<!DOCTYPE html><html><head><metacharset="utf-8"><scriptsrc="https://cdn.bootcss.com/angular.js/1.4.6/angular.min.js"></script></head><bodyng-app=""><form>
选择一个选项:
<inputtype="radio"ng-model="myVar"value="dogs">Dogs
<inputtype="radio"ng-model="myVar"value="tuts">Tutorials
<inputtype="radio"ng-model="myVar"value="cars">Cars
</form><divng-switch="myVar"><divng-switch-when="dogs"><h1>Dogs</h1><p>Welcome to a world of dogs.</p></div><divng-switch-when="tuts"><h1>Tutorials</h1><p>Learn from examples.</p></div><divng-switch-when="cars"><h1>Cars</h1><p>Read about cars.</p></div></div><p>ng-switch 指令根据单选按钮的选择结果显示或隐藏 HTML 区域。</p></body></html>
下拉菜单
<!DOCTYPE html><html><head><metacharset="utf-8"><scriptsrc="https://cdn.bootcss.com/angular.js/1.4.6/angular.min.js"></script></head><bodyng-app=""><form>
选择一个选项:
<selectng-model="myVar"><optionvalue=""><optionvalue="dogs">Dogs
<optionvalue="tuts">Tutorials
<optionvalue="cars">Cars
</select></form><divng-switch="myVar"><divng-switch-when="dogs"><h1>Dogs</h1><p>Welcome to a world of dogs.</p></div><divng-switch-when="tuts"><h1>Tutorials</h1><p>Learn from examples.</p></div><divng-switch-when="cars"><h1>Cars</h1><p>Read about cars.</p></div></div><p>ng-switch 指令根据下拉菜单的选择结果显示或隐藏 HTML 区域。</p></body></html>