2016-11-30 3 views
0

아래는 내 각도 컨트롤러AngularJS - 조건부 속성이 변수와 함께 작동하지 않습니까?

각도 JS

var multistage = angular.module("multistage", []); 

multistage.controller('groupStanding', function($scope1) { 
    $scope1.grouplimit = 3; 
    $scope1.competitorDTL = <?php echo json_encode($competitorDtl); ?>; 
    console.log($scope1.grouplimit); 
}); 

이며,이 아래에있는 내 HTML 코드 ...

HTML입니다

<tbody data-ng-controller="fixtureController"> 
     <tr data-ng-repeat="comp in competitorDTL"> 
     <td> 
      <span class="badge" data-ng-if="$index+1 <= grouplimit">   
      {{$index+1}}</span> {{ comp.name}} 
     </td> 

    </tr> 
    </tbody> 

그것의 작동하지 않는 및 문제가 무엇인지 정확히 알 수 없습니까? 변수를 grouplimit으로 바꾸고 3을 직접 입력하면됩니다.

+0

data-ng-controller="fixtureController" 변화에게 그것을 사용했다'다단계 .grouplimit'을 html로 보냅니다. –

+0

올바른 컨트롤러를 사용 중이라고 가정하면'{{grouplimit}} '에게 기회를주십시오. – Ksyqo

+0

선생님, multistage.grouplimit도 작동하지 않습니다 .. – Mikky

답변

0

컨트롤러 이름 'groupStanding'이며 data-ng-controller="groupStanding" 그것이 있어야

0

이 시도 :

{{groupelimit}} 

groupelimit이어서 해당 컨트롤러에서의 값으로 대체 될 것이다.

+0

아니요 작동하지 않습니다 .. – Mikky

0

당신이 놓친 '{'{$index+1}}

<td><span class="badge" data-ng-if="$index+1 <= grouplimit">{$index+1}}</span>{{ comp.name}} 

에 이유를 수

+0

이 또한 작동하지 않습니다 – Mikky

+0

내 배열 요소가 $ scope1 변수로 잘 인쇄되는데 왜 $ scope가 필요합니까? $ scope1 대신에? – Mikky

+0

죄송합니다. 사실 제가 질문을 쓰는 동안 여기에 착각했습니다. 그러나 문제는 여전히 존재합니다. – Mikky

관련 문제