で動作していない。Udating親オブジェクトは、Iが指令はそのような定義されたすべての
myApp.directive('someDirective', function() {
return {
restrict: 'A',
scope: {
disableButton: '=',
},
templateUrl: 'sometemplate.html',
controller: 'SomeDirectiveController'
}
})。
次のように指示するためのコントローラはなります
:mLoan.controller('GiversDirectiveController', function (
$scope,
) {
$scope.checkGiversAmount = function() {
var giversCurrentTotalValue = $scope.stocksTotalAmount - $scope.giversCurrentAmount;
}
このディレクティブビュー
<div class="row">
<div class="col-lg-2">
<label for="customer">Wybierz klienta</label>
<select id="customer"
name="customer"
class="form-control"
ng-model="selectedCustomerId"
ng-options="customer.Id as customer.Name for customer in customers"
ng-change="getGiversFunds(selectedCustomerId)"
required=""></select>
</div>
<div class="col-lg-2" ng-show="customerFunds.length > 0">
<label for="customerFunds">Wybierz fundusz</label>
<select id="customerFunds"
name="customerFunds"
class="form-control"
ng-model="selectedFundId"
ng-options="customerFund.Id as customerFund.Name for customerFund in customerFunds"
ng-blur="updateGiverFund(selectedCustomerId, selectedFundId)"
ng-required="customerFunds.length > 0"></select>
</div>
<div class="col-lg-2">
<label for="giversCurrentAmount">Ilość</label>
<input type="number" min="1"
max="{{giversCurrentAmount}}"
id="giversCurrentAmount"
name="giversCurrentAmount"
class="form-control"
ng-model="giversCurrentAmount"
ng-change="checkGiversAmount(selectedFundId)"
ng-blur="updateGiverStockAmount(selectedCustomerId, giversCurrentAmount)"
required />
</div>
<div class="col-lg-2">
<label for="commission">FEE%</label>
<input type="number"
min="1"
id="commission"
name="commission"
class="form-control"
ng-model="commission"
ng-blur="updateGiverCommission(selectedCustomerId, commission)"
required />
</div>
<div class="col-lg-4">
<label for="minimalCommission">FEE Min</label>
<input type="number"
min="1"
id="minimalCommission"
name="minimalCommission"
class="form-control"
ng-model="minimalCommission"
ng-blur="updateGiverMinimalCommission(selectedCustomerId, minimalCommission)"
required />
</div>
</div>
そして、私はボタンでディレクティブを使用しています親ビューであります
<div ng-repeat="giver in givers">
<div givers-directive givers="givers"
givers-current-amount="giversCurrentAmount"
disable-giver-side-add="parent"
stocks-total-amount="stocksTotalAmount">
</div>
</div>
<div class="row">
<div class="col-lg-12 margin-top-10px">
<button id="addGiverSide"
name="saveLoan"
class="btn btn-primary"
ng-click="addGiverSide(AddLoansForm)"
ng-disabled="disableButton">
Dodaj
</button>
</div>
</div>
今私の問題と質問athは、私がdisableButtonを更新する方法ですom親モデル。あなたはこれが重複していると言う前に、私は解決策tahtを実行したが、主にこの1つ:How to access parent scope from within a custom directive *with own scope* in AngularJS?とその1:What are the nuances of scope prototypal/prototypical inheritance in AngularJS?しかし、何も役立つようにstackoverflowにあった。 stranegとは何ですか(あるいはそうではありません)私は$親を使ってそれを得ることはできません。私は通過する必要があります:$ scope。$ parent。$ parent pathそしてそれは更新されています。それは醜いと奇妙に見えるだけでなく、私は親ビューからこの変数を更新しようとしているときに動作していない。要約すると、1つの効果が働いており、もう1つは効果がありません。そして、変更した後は逆です。無効なボタンをオブジェクトにまとめて、変更を試みようとしましたが、これも機能しません。あるいは、私はそれを間違ってやっているかもしれない。私がアイデアを使い果たしているので、親切に私を助けてください。私は間違って何をしていますか?
UPDATE
私は私がここで達成しようとしているどのような概念を示すために、ディレクティブビューの残りの部分を追加しています。私はそれらを独立させたいと思うドロップダウンです。分離された(または隔離された)スコープのディレクティブがなければ、2つのドロップダウンはもう一方のドロップを使って塗りつぶされます。私はそれらを独立して変えたい。私は孤立した範囲を通してthetを達成することができました。しかし、今私は無効にするボタンを働かせるように見えることはできません。
を、私はそれを試してみたが、これも助けにはなりませんでした。私は、ng-repeat指令も持っていることを発見しました。これはスコープも持っているので、おそらく私は$ scope。$ parent。$ parentに行きましょう。最初の$ parentはng-repeatレベルで、次のものは私が前に見ているものです。私はdirevtiveビューへのngの繰り返しを移動しました。そうするときに何が出てくるかを見ていきます。 –