點(diǎn)擊事件顯示或隱藏元素
PS:1:ng-show = " 關(guān)鍵字 " 定義一個ng-show方法的關(guān)鍵字。
PS:2:ng-click = "方法名( )" 定義一個方法名抖誉。
PS:3:$scope.contFlg = true; 先設(shè)置關(guān)鍵字為顯示狀態(tài)估脆。
PS:4:$scope.contFlg = !$scope.contFlg; 設(shè)置關(guān)鍵字狀態(tài)不相等钦奋。
<!doctype html>
<html ng-app = "myapp" ng-controller = "TestController">
<head>
<script src="http://code.angularjs.org/angular-1.0.1.min.js"></script>
</head>
<body>
<div>
<p ng-show = "contFlg">內(nèi)容</p>
<bottom ng-click = "HideContent()">點(diǎn)擊</bottom>
</div>
</body>
<script>
var app = angular.module('myapp', []);
app.controller('TestController', function($scope) {
$scope.contFlg = true;
$scope.HideContent = function (){
$scope.contFlg = !$scope.contFlg;
};
});
</script>
</html>
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者