angularjs-将文本突出显示在

时间:2018-05-26 06:18:41

标签: angularjs angularjs-ng-repeat

我是棱角分明的新手。所以,我想突出HTML中的某些文字。

HTML CODE:

                    <div class="form-label logs-wrap" ng-repeat="x in res track by $index" ng-click="getBookingLog(x.bookingDBID)" ng-class="{selected: x.bookingDBID === bookingDBID}">

                      <span class="form-label">{{x.xml}}</span>
                    </div>
                  </div>

我的CSS(仅限选定的课程):

.selected {
  background-color: red;
}

角色代码:

$scope.bookingDBID = null;
    $scope.getBookingLog = function(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) {
            // console.log(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',
              });
            }
       });

    }

我想在角度js中突出显示 bookingDBID ,但没有突出显示任何文字。

enter image description here

我希望在图像中高亮显示 152422082503328306779

reservation_notif_id = bookingDBID 结果商店

任何有任何想法的机构请帮忙解决。感谢

1 个答案:

答案 0 :(得分:1)

Check this plunkr

你可以拥有

xmlTransform = function(data) {
    var x2js = new X2JS();
    var json = x2js.xml_str2json( data );
    return json.guitars.guitar;
};

$http.get('guitars.xml', {transformResponse:xmlTransform}).
            success(function(data, status) {
                 $scope.dataSet = data;
            }).
            error(function(data, status) {
                console.log("Request failed " + status);
            });

并在html

<div ng-controller="AppController" >
 <ul>
    <li ng-repeat="guitar in dataSet">
       <div class="selected"> {{guitar.model}} </div> <!-- HERE YOU HAVE HIGHLIGHTED -->
       <div>{{guitar.introyear}}</div>
    </li>
  </ul>
</div>