ng-show,ng-hide无效

时间:2016-05-24 10:40:04

标签: angularjs angularjs-scope

ng-showng-hide无效。在我的控制器中我有 的 $scope.isHide=true ;这是工作。但是$scope在更改嵌套函数内的值时不会更新。代码说明如下,

 $scope.isHide=true //It works

  $scope.productdetails = function (size,selectedproduct)
     {
      var modalInstance = $uibModal.open({
        animation: $scope.animationsEnabled,
        templateUrl: '/Selection_Routing/Selection_Product/ProductDetails.html',
        controller: function ($scope, $uibModalInstance, product) {
            $scope.product = product;

            $scope.buy = function (path) {
                $uibModalInstance.close($scope.product);
                $location.path(path);
                $scope.isHide= false; // Not working
            };

        },            
    });
};

2 个答案:

答案 0 :(得分:0)

我认为你在这里想念的是将当前的$ scope传递给你的模态,

请尝试以下方法:

 $scope.isHide=true;

 $scope.productdetails = function (size,selectedproduct)
 {
  var modalInstance = $uibModal.open({
    animation: $scope.animationsEnabled,
    templateUrl:   '/Selection_Routing/Selection_Product/ProductDetails.html',
    scope: $scope, //passed current scope to the modal
    controller: function ($scope, $uibModalInstance, product) {
        $scope.product = product;

        $scope.buy = function (path) {
            $uibModalInstance.close($scope.product);
            $location.path(path);
            $scope.isHide= false;
        };

    },            
});
};

答案 1 :(得分:0)

也许如果binded属性是一个对象而不是一个原始的

        INSTALLED_APPS = (
            'django.contrib.admin',
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
            'django.contrib.messages',
            'django.contrib.staticfiles',
            #mongo
        )

        MIDDLEWARE_CLASSES = (
            'django.contrib.sessions.middleware.SessionMiddleware',
            'django.middleware.common.CommonMiddleware',
            'django.middleware.csrf.CsrfViewMiddleware',
            'django.contrib.auth.middleware.AuthenticationMiddleware',
            'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
            'django.contrib.messages.middleware.MessageMiddleware',
            'django.middleware.clickjacking.XFrameOptionsMiddleware',
            'django.middleware.security.SecurityMiddleware',

        )


        # Database -MONGODB
        DATABASES = {
            'default': {
                'ENGINE': 'django.db.backends.dummy'
            }
        }

        from mongoengine import connect
        connect('employeedb', username='woosungchu', password='1234')

        SESSION_ENGINE = 'mongoengine.django.sessions'
        SESSION_SERIALIZER = 'mongoengine.django.sessions.BSONSerializer'