0

そのため、シームレスなデータバインディングのために、進行中の古いサイトを jquery の代わりに angular を使用するように変換し始めました。

これで、データセットが取り込まれているこの選択ができました。

<select ng-model="affiliation" ng-options="row.desc for row in affiliationTable"> <!--group by row.id-->
     <option value=""> Select an existing affiliation</option>
</select>

ユーザーがテーブルのアンカー タグをクリックすると、対応する「所属」が選択で選択されるようにしたいので、テーブルは次のようになります。

<tr ng-repeat="row in tableData">  <!--{{row.name}}-->
     <td><a href='#' ng-click="invokeModal();" onclick="lastClickedMember=this.id;" id="{{row.id}}">{{row.name}}</a></td>
     <td>{{row.active}}</td>
     <td>{{row.end_date}}</td>
     <td>{{row.start_date}}</td>
</tr>

特定のオプションを選択するために使用したコードは次のとおりです。

$scope.invokeModal = function(){ //memberDescription

    for(var row in $scope.tableData){
        if($scope.tableData[row].id == lastClickedMember){
            $scope.selectedMembershipDescription = $scope.tableData[row].desc;


            $scope.selectedMembershipId = lastClickedMember;
            $scope.selectedEndDate = $scope.tableData[row].end_date;
            $scope.selectedStartDate = $scope.tableData[row].start_date;
        }

        if($scope.affiliationTable[row].id == lastClickedMember){
            $scope.affiliation = $scope.affiliationTable[row]; //$scope.selectedMembershipDescription;
        }
    }

    jQuery("#mem").modal('show');
};

もちろん、このコードと他のいくつかのオプションを試した後でも、私の選択にはまだオプションが設定されていません。

誰か助けてください。

編集 ここでは、テーブルにデータが入力される方法を示します。

$http(
    {
        url: "http://localhost/get_info.php",
        method: "POST",
        data: "filter=membership&cid=2",
        headers: {'Content-Type': 'application/x-www-form-urlencoded'}
    }
).
success(function(data, status, headers, config) {
    // this callback will be called asynchronously
    // when the response is available
    //alert("first row: " + data.name[0]);
    for(var row in data.name){
        $scope.tableData.push({id:data.name[row][0], name:data.name[row][5], active:(data.name[row][1] == "0") ? "Not Active" : "Active", end_date:data.name[row][3], start_date:data.name[row][2]});
    }
});

//get affiliation table
$scope.affiliationTable = [];

$http({
        url: "http://localhost/get_info.php",
        method: "POST",
        data: "filter=affiliation",
        headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(data, status, headers, config) {
    // this callback will be called asynchronously
    // when the response is available

    for(var row in data.name){
        $scope.affiliationTable.push({id:data.name[row][0], desc:data.name[row][1]});
    }
});
4

1 に答える 1