私はルールのリストを設定するテーブルを持っています。チェックボックスがクリックされると、私はこれらの "真の"値をとり、APIエンドポイントに投稿する必要があります。これは設定されていますが、私が戻ってきたのは "associated_rule"が定義されていないということです。postメソッドのanglejsのチェックボックスの結果の表示
コントローラに$scope.associated_rule.selected = true;
を設定しようとしましたが、これは変数を定義しておらず、同じエラーをコンソールにスローします。ここで
が私のHTMLフォームです:
<form name="rules_form" method="post" ng-submit="attach()">
<table class="table table-striped table-hover" ng-model="associated_rules">
<thead>
<th>Rule Types:</th>
<th>Description:</th>
<th>Start Time:</th>
<th>End Time:</th>
<th>Apply Rule to Vehicle:</th>
</thead>
<tr ng-repeat="associated_rule in associated_rules">
<td>@{{ associated_rule.resource_ids.accounts }}</td>
<td>@{{ associated_rule.description }}</td>
<td>@{{ associated_rule.start_time }}</td>
<td>@{{ associated_rule.end_time }}</td>
<td><input type="checkbox" ng-model="associated_rule.selected" aria-label="rule"></td>
</tr>
</table>
<button class="btn btn-primary" ng-click="attach()">Attach</button>
</form>
私のコントローラのイベント:
$scope.attach = function() {
$scope.associated_rule.selected = true;
var i;
for (i = 0; i < $scope.associated_rule.selected.length; i++) {
//need to create a loop where the true value is picked up and then I can send the data using a POST method. But I'm stuck on this.
}
console.log(the result of the event);
};
今のところ、私は結果がCONSOLE.LOGしたいので、私は、イベントが作成されていることがわかりますループを実行して結果を表示します。その後、私はOKになるはずです。
ご協力いただければ幸いです。