搜索数据并在包含输入搜索字段的打开模式对话框中显示

时间:2017-09-28 13:17:58

标签: angularjs html5 ng-dialog

您好我创建了一个功能,可以根据模式对话框输入字段中的输入帐号来搜索和从数据库中获取客户端数据,如果找到则在同一对话框中显示详细信息。但如果发现数据,则不会显示,并且“无数据”的响应显示为必需

代码如下: -

            scope.fetchClientInfo = function() {
                resourceFactory.clientResource.get({clientId: savingaccount.clientId }, function (data) {
                    scope.client = data;
                });
            };

            scope.fetchAccountInfo = function() {
                var searchString = scope.searchText;
                scope.savingaccount = [];
                var searchString = scope.searchText;
                var exactMatch = true;
                resourceFactory.globalSearch.search({query: searchString, resource: "savings", exactMatch: exactMatch}, function (data) {
                    scope.savingaccount = data;
                    if (data.length > 0) {
                        fetchClientInfo();
                    } else{
                        Alert('No account found');
                        scope.searchText = "";
                    }
                });
            };

HTML

         <div class="divTable">
            <div class="divTableBody">
                <div class="divTableRow">
                    <div class="divTableCell">
                        <p class=MsoNormal align=right><span>Account Number:</span></p>
                    </div>
                    <div class="divTableCell">
                        <p class=MsoNormalvalue>
                        <input class="form-control1" type="text" name="accountNumber" id="accountNumber" data-ng-model="searchText" required/>

                            <button class="ngdialog-button" ng-click="closeThisDialog()">Search and Display</button>
                        </p>
                    </div>
                </div>
             </div>
           </div>

此处显示的客户信息: -

<table class="pretty displayschedule" style="position:relative;bottom:15px;">
    <tr>
        <td valign=middle><p class=MsoNormal align=right><span>CID:</span></p>
        </td>
        <td valign=middle style="width:183px"><p class=MsoNormalvalue><span>{{client.externalId}}</span></p></td>
    </tr>
    <tr>
        <td valign=middle><p class=MsoNormal align=right><span>Savings Product:</span></p></td>
        <td valign=middle><p class=MsoNormalvalue><span>{{savingaccount.productName}}</span></p></td>
    </tr>
    <tr>
        <td valign=middle><p class=MsoNormal align=right><span>Saving Account Number:</span></p></td>
        <td valign=middle>
            <p class=MsoNormalvalue><span>{{savingaccount.accountNo}}</span></p>
        </td>
    </tr>
    <tr>
        <td valign=middle><p class=MsoNormal align=right><span>NID:</span></p></td>
        <td valign=middle><p class=MsoNormalvalue><span>{{client.nationalId}}</span></p>
        </td>
    </tr>
    <tr>
        <td valign=middle><p class=MsoNormal align=right><span>Address:</span></p></td>
        <td valign=middle><p class=MsoNormalvalue><span >{{client.address}}</span></p>
        </td>
    </tr>
</table>

0 个答案:

没有答案