J
J
jenya77712016-12-03 15:55:35
Angular
jenya7771, 2016-12-03 15:55:35

How to change ng-if value from controller?

<div class="office-block" ng-if="true">
</div>

myApp.controller("homeCtrl", function($scope, $location){

  $scope.saveOffice = function (office) {
    $scope.clientsInfo = office;

    if (office != ""){
      // код который будет изменять ng-if
    };

  };

});

How do I change the value of ng-if with a controller?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kirill Sharonov, 2016-12-04
@k_sharonov

ng-if="function()"
function() {
If () return true
else
return false
}

S
Stepanya, 2016-12-09
@Stepanya

<div class="office-block" ng-if="isShow">
</div>

myApp.controller("homeCtrl", function($scope, $location){
  $scope.isShow = false;

  $scope.saveOffice = function (office) {
    $scope.clientsInfo = office;

    if (office != ""){
      // код который будет изменять ng-if
      $scope.isShow = !$scope.isShow;
    };

  };

});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question