2016-07-22 8 views
0

以下のコードでは、親div [class = timeAllot]内でどこでも、変更を行うときに(am、pm、nameなどの入力ボタンで)、ボタンdiv [div class = "buttons"]要素が表示されます。最初に、ページが読み込まれるとき、それは見えないはずです。ng-repeatで現在のスコープ要素をどのようにターゲットにするか

最初のdivを変更するときにクラスボタンのdivをすべて表示させるべきではありません。divを変更するだけです。つまり、最初の 'timeAllot' divで変更すると、最初に表示されないようにする必要があります。div [div class = "buttons"]

問題がすべて表示されるようになりました。私のコントローラ上の

、私はこのコードを持っている:HTMLで

$scope.items = [{hours: 24, place: 'india'}, {hours: 24, place: 'uk'}, {hours: 24, place: 'USA'}]; 
$scope.dataItems = ['Items1', 'Item2', 'Item3']; 

$scope.displaySaveCancel = false; 

$scope.checkthiStuff = function(indexValue){ 
    console.log("Check this stufff...", indexValue); 
    $scope.displaySaveCancel = true; 

}; 

<div class="timeAllot" ng-repeat="item in items" ng-change="checkthiStuff($index)"> 

    Name: <input type="text" name="name" ng-model="name"/> 

    <div class="infos" ng-repeat="data in dataItems"> 
     AM: <input type="text" name="am" ng-model="am"/> 
     PM: <input type="text" name="pm" ng-model="pm"/> 
    </div> 

    <div class="buttons" ng-show="displaySaveCancel === true"> 
    <button>save</button> 
    <button>cancel</button> 
    </div> 

</div> 
+0

問題を示すためにプランナーを提供できますか? – developer033

答えて

0

は、現在の要素の$index、コントローラで

<div class="infos" > 
    AM: <input type="text" data-ng-change="checkthiStuff($index)" name="am" ng-model="am"/> 
    PM: <input type="text" data-ng-change="checkthiStuff($index)" name="pm" ng-model="pm"/> 
</div> 

<div class="buttons" ng-show="currentIndex === $index"> 
    <button>save</button> 
    <button>cancel</button> 
</div> 

を使用します
$scope.currentIndex = -1; 
$scope.checkthiStuff = function(indexValue){ 
    $scope.currentIndex = indexValue; 

}; 
+0

私のコードを見てください、私は私のコードをいくつか変更しました。 – User123

関連する問題