You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AngularJS中高亮bookingDBID文本问题求助

Fixing the Highlight Issue for Your AngularJS Booking Logs

Hey there! I see exactly why your highlighting isn't working—let's get this sorted out quickly.

The Root Cause

Right now, when you click a log entry, you pass the bookingDBID to your getBookingLog function, but you never update the global $scope.bookingDBID variable that your ng-class condition depends on. Your ng-class="{selected: x.bookingDBID === bookingDBID}" checks against $scope.bookingDBID, which stays stuck as null forever. That's why the red background never triggers!

The Simple Fix

All you need to do is add one line inside your getBookingLog function to update $scope.bookingDBID with the clicked entry's ID. Here's the modified Angular code:

$scope.bookingDBID = null; 
$scope.getBookingLog = function(bookingDBID){ 
    // Add this line to sync the clicked ID with your scope variable
    $scope.bookingDBID = bookingDBID;

    $scope.book = {}; 
    $scope.book.PID = $stateParams.id; 
    $scope.book.bookingDBID = bookingDBID; 
    $scope.showloader=true; 
    var Indata ='data='+angular.toJson($scope.book)+'&method=getBookingLog&service=bookings'; 
    $http({ 
        method: 'POST', 
        url: 'sl/service/middleservice.php', 
        headers: {'Content-Type': 'application/x-www-form-urlencoded'}, 
        data: Indata 
    }).success(function (response) { 
        $scope.showloader=false; 
        if(response == 'noSession') { 
            location.href = 'login.php'; 
        }else { 
            if(response) { 
                $scope.res = response.reverse(); 
                $scope.cnt = $scope.res.length; 
            } 
            $scope.loadingdiv= false; 
            $scope.$modalInstance1 = $modal.open({ 
                scope: $scope, 
                templateUrl: "bookinglog.html", 
                size: 'lg1', 
            }); 
        } 
    }); 
}

How This Works

When you click a log entry:

  1. We immediately set $scope.bookingDBID to the clicked entry's ID
  2. The ng-class condition now matches the clicked entry's bookingDBID against the updated scope variable
  3. The selected class (red background) will be applied to the clicked entry right away

Quick Double-Check

Make sure the bookingDBID values in your res array are the same data type (string/number) as the one stored in $scope.bookingDBID. If one's a string and the other's a number, the strict equality (===) won't match. If that happens, you can either use loose equality (==) or convert both to the same type (e.g., parseInt(bookingDBID) if they're numeric IDs).

内容的提问来源于stack exchange,提问作者Paras Prajapati

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 06:56:33