點(diǎn)擊事件顯示或隱藏元素
PS:1:ng-show = " 關(guān)鍵字 " 定義一個(gè)ng-show方法的關(guān)鍵字。
PS:2:ng-click = "方法名( )" 定義一個(gè)方法名。
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)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。