如何在从 Web API 加载数据后将文件管理器添加到页面



我正在开发酒店预订网站。我已经完成了对来自 WebAPI 的负载数据的开发。我想在页面加载后添加过滤器。

脚本

function getAll() {
    var sub = {
        Des: $scope.Des,
        DepartureDate: $scope.DepartureDate,
        ReturnDate: $scope.ReturnDate,
        Rooms: $scope.Rooms,
     };
    var getAll = APIService.hotelavailability(sub);
    getAll.then(function (d) {
        console.log("Succss");
        $scope.respData = d.data.hotels;
    }, function (error) {
        console.log('Oops! Something went wrong.');
}

CHTML 代码

<div class="hotel_filter">
 <input ng-model="hotelName" class="form-control" placeholder="Search hotel" type="text" id="searchbox">
</div>
<div ng-repeat="hotel in respData.hotels" class="clearfix">  
 <h2>{{hotel.name}}</h2>
</div>

如何从输入框(搜索框(加载页面后过滤酒店数据?

看看这个。这正是您所描述的。https://docs.angularjs.org/api/ng/filter/filter .那里显示了示例,但在这里你去:

<div class="hotel_filter">
 <input ng-model="hotelName" class="form-control" placeholder="Search hotel" type="text" id="searchbox">
</div>
<div ng-repeat="hotel in respData.hotels | filter:hotelName" class="clearfix">  
 <h2>{{hotel.name}}</h2>
</div>

相关内容

最新更新