Is there a way to do a ng-hide on a html div?

后端 未结 4 1900
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-24 03:53

I am trying to hide my div that has id=\"crossfade\" where there is an ng-click event.

1) Is this possible? 2) What am I doing wrong?



        
4条回答
  •  隐瞒了意图╮
    2021-01-24 04:49

    If they are in the same controller you can just set a scope variable to ng-hide. something like:

    $scope.hideCrossfade = false;
    
    function getData(mType) {
        $scope.hideCrossfade = true;
    }
    

    and in your html

    If your header controller and content controller are split up, you will want to use a $broadcast

    in your headerController:

    $scope.getData = function(mType) {
        $scope.$broadcast('hideCrossfade', true);
    };
    

    and in your content controller

    var deregisterFn = $scope.$on('hideCrossfade', function($event, hide) {
        $scope.hideCrossfade = hide;
    };
    

提交回复
热议问题