ng-show 指令在表示式為 true 時顯示指定的 HTML 元素,否則隱藏指定的 HTML 元素。下面是示例:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>demo4</title> <script type="text/javascript" src="lib/angularjs/angular.min.js" charset="utf-8"></script> </head> <body ng-app=""> <div ng-init="checked=true"> <label> <input type="checkbox" ng-model="checked"> Is Visible... </label> <div ng-show="checked"> Visible... </div> </div> </body> </html>