2015-11-27 63 views
0
<tbody ng-repeat="T in sal "> 
      <!--| filter:search:strict" >--> 
      <tr id="tr{{T.id}}" ng-class-odd="'odd'" ng-class-even="'even'"> 

       <td > 

        <div class="form-group" ng-repeat="K in datavalue"> 
    <div ng-show="(p.id == K.emp_id && T.id == K.component_id)" ng-init="hideinputbox(T.id)"> 
     {{K.amount}} 
    </div> 

</div> 
<input type="text" placeholder="Enter valueg" class="form-control" name="cvalue" id="{{T.id}}" ng-model="T.cvalue" required/> 

</tr> 
     </tbody> 
     </table> 
     </form> 

內部控制,隱藏和顯示在NG重複

$scope.hideinputbox = function (k) { 

     $("input#k").hide(); 
    } 

我的問題是隱藏輸入框,如果表達式爲true。 如果我手動給出ID,它隱藏了輸入框,但在循環內部它不起作用。我相信,這條線是造成該問題:

<input type="text" placeholder="Enter valueg" class="form-control" name="cvalue" id="{{T.id}}" ng-model="T.cvalue" required/> 
+1

儘量不要使用jQuery有角的js一起。它的作用是一個不好的做法。 – katmanco

回答

3

你的功能是wrong.You始終調用函數與ķķ變量。改變你的代碼是這樣的:

$scope.hideinputbox = function (k) { 

     $("input#" + k).hide(); 
    } 

而作爲@katmanco說,不要使用jQuery和AngularJS。

但你爲什麼要隱藏你的元素,也有ng-show

<div ng-show="(p.id == K.emp_id && T.id == K.component_id)" ng-init="hideinputbox(T.id)"> 
     {{K.amount}} 
    </div> 

如果您ng-show="condition"是假的,將被隱伏,所以我認爲你不需要

+0

非常感謝你... – athira