How to use an Ng-if with Firebase

前端 未结 2 557
陌清茗
陌清茗 2021-01-28 11:56

I know that the ng-if directive creates a new child scope and I would like to know HOW and IF it is possible to play a ng-if into an other one.

For now I can\'t see any

2条回答
  •  礼貌的吻别
    2021-01-28 12:36

    I suggest to use the controllerAs syntax to ensure correct scope access and control.

    HTML:

    
      

    Parent is allowed

    Children are allowed
    Children are allowed

    JS

    var app = angular.module('plunker', []);
    
    app.controller('MainCtrl', function($scope) {
      var allowParent_ = true;
      var allowChildren_ = false;
      this.toggle = function() {
        allowChildren_ = !allowChildren_;
      }
      this.showParent = function(){
        return allowParent_;
      }
    
      this.showChildren = function() {
        return allowChildren_;
      }
    });
    

提交回复
热议问题