国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

angular.js - angularJS How to use .directive directive to display when clicked and then disappear when clicked again.
黃舟
黃舟 2017-05-15 17:00:04
0
2
597

$scope.facePanel = false;

    $scope.showFace = function () {
        $scope.facePanel = !$scope.facePanel;
    }
    這是我在controller里面的代碼
黃舟
黃舟

人生最曼妙的風景,竟是內心的淡定與從容!

reply all(2)
洪濤

How can you click on the element to display it again if it is already hidden?
If you click a button to hide another element, it is still easy to implement!
html

<button ng-click="showFace()">點擊</button>
<p ng-show="facePanel">要顯示或隱藏的元素</p>

No need for functions, just change it a little
<button ng-click="$scope.facePanel=!$scope.facePanel">click</button>

伊謝爾倫

js

angular.directive('aDirective', [function(){
    return {
        restrict: 'E',
        template:'<p a-directive><p ng-show="facePanel">元素</p><button ng-click="showFace()">點擊</button></p>',
        replace: true,
        link: function(scope, ele, attr){
            scope.facePanel = false;
            scope.showFace = function () {
                scope.facePanel = !$scope.facePanel;
            } 
        }
    }
}])

html

<a-directive></a-directive>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template