2016-06-27 1 views
2

탭을 선택하고 2 개의 버튼을 표시하고 싶습니다.

은 그래서 이것은 내 영문 코드 :

<button id="UxMoveAllRight" style="width: 40px; height: 25px; margin-top: 20px;" ng-show="showMoveallButtons()"> 
           <i class="pi-icon pi-icon-angle-double-right"></i> 
          </button> 
          <button id="UxMoveAllLeft" style="width: 40px; height: 25px; margin-bottom: 20px;" ng-show="showMoveallButtons()"> 
           <i class="pi-icon pi-icon-angle-double-left"></i> 
          </button> 

이것은 (controller.js에서) 내 NG 쇼 기능 코드 :

$scope.showMoveallButtons = function() { 
        var show = false; 
        $timeout(function() { 
         var activetab = $find("Add").get_selectedTab().get_name(); 
         if (activetab == "AddBulk") { show = true } 
         else { show = false }; 
        }); 
        return show; 
       }; 

하지만 항상 false를 돌려줍니다. 선택 탭이 AddBulk와 같으면 2 버튼이 표시되지 않습니다.

항상 잘못된 이유를 반환합니다. timeout?

어떻게 해결할 수 있습니까?

+2

ode'return show;는'return false;와 같습니다 ** 항상 ** – Tushar

+0

무슨 뜻입니까? @tushar를 잘못하고있는 곳 – eagle

+0

'ng-show'를 스코프 속성으로 지정하고 타임 아웃 내에서 변경하십시오. –

답변

0

이 시도 :

$ 제한 시간 (함수() { VAR activetab = $ 찾기() "추가"를 get_selectedTab() get_name를(); 경우 (activetab == "AddBulk").. {show = true} else {show = false}; return show; }});

+0

doesnt work @MiloShen – eagle

+1

이것은 $ timeout()이 비동기 함수이기 때문에 최선의 방법은 아닙니다. $ timeout 이후의 코드는 항상 그 전에 실행됩니다. –

0

은 그냥 ($ 시간 제한)

'엄격한 사용'컨트롤러에 넣어;

app.controller('ctrlname', ['$scope','$http','$timeout', function($scope,$http,$timeout){ 

     ...... 
     ...... 
}]); 
당신의 timeOut()
+0

이미 @JaydeepGondaliya를 추가했습니다. – eagle

+0

http://jsfiddle.net/ganarajpr/lqge2/ –

0

사용 $scope.show하고 지시에 그녀에 영향을 ng-show.

JS

$scope.showMoveallButtons = function() { 
        $timeout(function() { 
         var activetab = $find("Add").get_selectedTab().get_name(); 
         if (activetab == "AddBulk") { $scope.show= true } 
         else { $scope.show= false }; 
        },/*Your delay here*/); 
       }; 

하여 C에서 HTML

<button id="UxMoveAllRight" style="width: 40px; height: 25px; margin-top: 20px;" ng-show="show">