Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS:我如何展示一个“^”&引用;仅当他们单击价格标签按价格排序时才使用箭头_Javascript_Angularjs - Fatal编程技术网

Javascript AngularJS:我如何展示一个“^”&引用;仅当他们单击价格标签按价格排序时才使用箭头

Javascript AngularJS:我如何展示一个“^”&引用;仅当他们单击价格标签按价格排序时才使用箭头,javascript,angularjs,Javascript,Angularjs,我只想在他们单击“价格”标签以按项目的最低到最高价格排序时显示span标记 <th id="tbl-labels" ng-click="orderByMe('price')">Price<span id="small">lowest price</span></th> price最低价格 这是完整的控制器代码 <body ng-app="app" ng-controller="MainController"> <div

我只想在他们单击“价格”标签以按项目的最低到最高价格排序时显示span标记

<th id="tbl-labels" ng-click="orderByMe('price')">Price<span id="small">lowest price</span></th>
price最低价格
这是完整的控制器代码

<body ng-app="app" ng-controller="MainController">
    <div id="outPopUp">
    <svg></svg>
    </div>
    <p id="search-txt">Search an item</p>
    <input id="rounded" text" ng-model="searchfor" />
    <div id="container">
    <table border="0" width="100%">
        <tr>
            <th id="tbl-labels" ng-click="orderByMe('product')">Product</th>
            <th id="tbl-labels" ng-click="orderByMe('price')">Price<span id="small">lowest price</span></th>
            <th id="tbl-labels">Link</th>
        </tr>
        <tr id="tr-items" ng-repeat="deal in deals | filter:searchfor | orderBy:myOrderBy">
            <td id="product">{{deal.product}}</td>
            <td id="price">${{deal.price}}</td>
            <td id="url">{{deal.link}}</td>
        </tr>
    </div>
    </body>

搜索项目

span id=“small”必须具有ng show或ng hide,并且在执行orderByMe时应更新表达式

<th id="tbl-labels" ng-click="orderByMe('price')">Price<span ng-show="isLowestToHigher" id="small">lowest price</span></th>
span id=“small”必须具有ng show或ng hide,并且在执行orderByMe时应更新表达式

<th id="tbl-labels" ng-click="orderByMe('price')">Price<span ng-show="isLowestToHigher" id="small">lowest price</span></th>

首先,将id重命名为“small”,使其更能代表您要完成的任务。比如“按价格过滤”

然后在orderByMe函数中:

function orderByMe(property) {
...
...
  if(property === 'price') {
     $("filter-by-price").addClass("lowtohigh");
  }
}
然后在css中,您可以执行以下操作:

#filter-by-price .lowtohigh::after { 
    content: " ^"; 
} 
您还可以将函数更改为切换筛选,只需添加另一个类来处理该问题

#filter-by-price .hightolow::after { 
    content: " ˅"; 
} 

首先,将id重命名为“small”,使其更能代表您要完成的任务。比如“按价格过滤”

然后在orderByMe函数中:

function orderByMe(property) {
...
...
  if(property === 'price') {
     $("filter-by-price").addClass("lowtohigh");
  }
}
然后在css中,您可以执行以下操作:

#filter-by-price .lowtohigh::after { 
    content: " ^"; 
} 
您还可以将函数更改为切换筛选,只需添加另一个类来处理该问题

#filter-by-price .hightolow::after { 
    content: " ˅"; 
} 

声明变量$scope.clickedValue=false; 在单击价格时使其为真,然后使用ng show指令

<th id="tbl-labels" ng-click="orderByMe('price')">Price<span ng-show="clickedPrice" id="small">lowest price</span></th>
price最低价格

希望能有帮助

声明变量$scope.clickedValue=false; 在单击价格时使其为真,然后使用ng show指令

<th id="tbl-labels" ng-click="orderByMe('price')">Price<span ng-show="clickedPrice" id="small">lowest price</span></th>
price最低价格

希望能有帮助

您可以在模型中设置一个标记,如
isOrdered
,然后ng显示该标记是否正确。您可以在模型中设置一个标记,如
isOrdered
,然后ng显示该标记是否正确`$scope.clickedPrice=false$scope.orderByMe=函数(q){this.myOrderBy=q;if($scope.myOrderBy='price'){this.clickedPrice=true;}否则{$scope.clickedPrice=false;};`$scope.clickedPrice=false$scope.orderByMe=函数(q){this.myOrderBy=q;if($scope.myOrderBy='price'){this.clickedPrice=true;}否则{$scope.clickedPrice=false;}`