2016-03-31 19 views
1

yılında uygulanması değil ng -eğer burada HTML, içinde:Ng-ben güncellemeniz gerekir Görünüm

<div id="shyBoxII" ng-if="robot.robot" ng-class="background"> 
    <div class="row"><i class="fa fa-user-plus"></i></div> 
    <div class="row"><i class="fa fa-book"></i></div> 
    <div class="row"><i class="fa fa-video-camera"></i></div> 
    <div class="row"><i class="fa fa-volume-up"></i></div> 
    </div> 

Ama benim denetleyicisi, ben true olsun, robot.robot log teselli ve hala #shyBoxII yok ortaya çıkmak. Ne verir?

$scope.pinActiveSection = function ($event,section) { 
      var $element = $(".table-hover tr."+section+""); 
      console.log($event,section); 
      if($element.children(":first").hasClass("unlock")){ 
      $(".table-hover tr:not(."+section+")").fadeOut("slow", function() { 
      $(this).remove(); 
      $element.parent().parent().parent().css("top", "10%"); 
      $element.parent().parent().parent().css("padding", "0%"); 
      $scope.activeSection.activeSection = section; 
      $scope.robot.robot = true; 
      console.log($scope.robot.robot); 
      if($scope.activeSection == "I") 
      { 
       $scope.background.push("I"); 
       $scope.background.push("show"); 
      } 
      }); 
      } 
      else{ 
       $.fn.extend({ 
      animateCss: function (animationName) { 
       var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend'; 
       $(this).addClass('animated ' + animationName).one(animationEnd, function() { 
        $(this).removeClass('animated ' + animationName); 
       }); 
      } 
     }); 
     $element.children(":first").animateCss('bounce'); 
      } 
     }; 

$scope.pinActiveSection Ben $scope.robot.robot true olduğunu konsol günlüğüne bakın, çalışan, yani benim bakış değil güncelleştirme neden anlamıyorum, Açık olmak gerekirse. $scope.robot.robot'u if bloğuna bastığımda çalışır, ancak ben fadeOut geri aranmasının bir parçası olarak istiyorum. Lütfen yardım et!

Düzenleme: Bir satırda iki kez pinActiveSelection çalıştırırsam, ikinci çalışmadan sonra #shyBoxII'u görüyorum. Bu, ilk kez yanlış giden şey hakkında herhangi bir ipucu veriyor mu?

+0

normalde ng-tekrarı veya bu kodu kullanıyor? –

+0

@ShailendraSinghDeol normalde –

cevap

1

fonksiyonun sonuna bu kodu ekleyin 'pinActiveSection'

$scope.$apply(); Ya $scope.$digest();

0

ng-show kullanmayı denediniz mi?

<div id="shyBoxII" ng-show="robot.robot" ng-class="background"></div> 
+0

Aynı problem! :( –

+0

{{robot.robot}} bir şey yazdırmak gelmez html'nizin bu yapıyor deneyin? Eğer kontrolör html'nizin üzerinde tanımlı var?

? –

+0

@FrederickMfinanga {{robot.robot}} baskılar 'true' –

0

sorun yok $digest() yeni değerle eski değerini karşılaştırmak için tetiklenir çünkü Açısal $scope.robot.robot değeri ilk kez güncellenir bilmiyor olabilir.

$timeout (function() { 
    $scope.robot.robot = true; 
}) 

Veya $scope.$evalAsync() yerine $timeout() kullanın: kullanın deneyin.