Posted in Javascript onDecember 29, 2017
本文实例讲述了Angular实现点击按钮控制隐藏和显示功能。分享给大家供大家参考,具体如下:
先来看看运行效果:
具体代码如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>3water.com Angular显示隐藏</title> <style> .box{ width: 100px; height: 100px; background: red; } </style> <script src="angular.min.js"></script> <script> var myapp=angular.module("myapp",[]); myapp.controller("myCtrl",function ($scope) { $scope.show=true; $scope.fun=function () { $scope.show=!$scope.show; console.log($scope.show); } $scope.hide=true; $scope.func=function () { $scope.hide=!$scope.hide; } }) </script> </head> <body ng-app="myapp" ng-controller="myCtrl"> <div class="box"ng-show="show"></div> <button ng-click="fun()">点击切换</button> <div ng-class="{box:hide}"></div> <button ng-click="func()">按钮</button> </body> </html>
希望本文所述对大家AngularJS程序设计有所帮助。
Angular实现点击按钮控制隐藏和显示功能示例
- Author -
当爱0201声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@