如何查找以下代码中选择框上的值更改时触发哪个函数或事件

发布于 2025-01-19 13:08:16 字数 1305 浏览 3 评论 0原文

<p>${Agenda Items Widget}</p>
<div id="pending-agenda-item-widget" class="panel panel-default" role="region" tabindex="0" aria-label="${Agenda Items Widget}" accessibility="{{meeting.accessible}}">
  <div class="panel-heading heading widget-heading heading-border" ng-class="{'heading-inactive': meeting.viewingCurrent()}">
      <div class="flex">
        <label for="cab-pending-agenda-filter" class="sr-only">${Agenda list filter}</label>
        <select id="cab-pending-agenda-filter" class="sn-select-basic expand" ng-model="selectedItem" ng-init="selectedItem = CAB.PENDING" ng-disabled="page.loading" tabindex="0">
          
            <option value="{{::CAB.PENDING}}">{{::c.data.i18n.filter[CAB.PENDING]}}</option>
            <option value="{{::CAB.ALL}}">{{::c.data.i18n.filter[CAB.ALL]}}</option>
            <option value="{{::CAB.MINE}}">{{::c.data.i18n.filter[CAB.MINE]}}</option>
            <option value="{{::CAB.APPROVED}}">{{::c.data.i18n.filter[CAB.APPROVED]}}</option>
            <option value="{{::CAB.COMPLETE}}">{{::c.data.i18n.filter[CAB.COMPLETE]}}</option>
        </select> 
        

我想知道哪个功能在选择框“驾驶室待办事项”中的价值变化时会触发,然后将值添加到同一函数

<p>${Agenda Items Widget}</p>
<div id="pending-agenda-item-widget" class="panel panel-default" role="region" tabindex="0" aria-label="${Agenda Items Widget}" accessibility="{{meeting.accessible}}">
  <div class="panel-heading heading widget-heading heading-border" ng-class="{'heading-inactive': meeting.viewingCurrent()}">
      <div class="flex">
        <label for="cab-pending-agenda-filter" class="sr-only">${Agenda list filter}</label>
        <select id="cab-pending-agenda-filter" class="sn-select-basic expand" ng-model="selectedItem" ng-init="selectedItem = CAB.PENDING" ng-disabled="page.loading" tabindex="0">
          
            <option value="{{::CAB.PENDING}}">{{::c.data.i18n.filter[CAB.PENDING]}}</option>
            <option value="{{::CAB.ALL}}">{{::c.data.i18n.filter[CAB.ALL]}}</option>
            <option value="{{::CAB.MINE}}">{{::c.data.i18n.filter[CAB.MINE]}}</option>
            <option value="{{::CAB.APPROVED}}">{{::c.data.i18n.filter[CAB.APPROVED]}}</option>
            <option value="{{::CAB.COMPLETE}}">{{::c.data.i18n.filter[CAB.COMPLETE]}}</option>
        </select> 
        

i want to know which function is getting triggered on change of value on the select box "cab-pending-agenda-filter" and pass adding value to the same function

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

热鲨 2025-01-26 13:08:16

只需将Onchange指令添加到您的选择元素:

<label for="cab-pending-agenda-filter" class="sr-only">${Agenda list filter}</label>
<select 
id="cab-pending-agenda-filter" 
class="sn-select-basic expand" 
ng-model="selectedItem" 
   ng-change="selectChanged(selectedItem)"
ng-init="selectedItem = CAB.PENDING" 
ng-disabled="page.loading" 
tabindex="0">
          
            <option value="{{::CAB.PENDING}}">{{::c.data.i18n.filter[CAB.PENDING]}}</option>
            <option value="{{::CAB.ALL}}">{{::c.data.i18n.filter[CAB.ALL]}}</option>
            <option value="{{::CAB.MINE}}">{{::c.data.i18n.filter[CAB.MINE]}}</option>
            <option value="{{::CAB.APPROVED}}">{{::c.data.i18n.filter[CAB.APPROVED]}}</option>
            <option value="{{::CAB.COMPLETE}}">{{::c.data.i18n.filter[CAB.COMPLETE]}}</option>
        </select>

然后在包含选择框的控制器的$范围中定义分配的方法:

$scope.selectChanged =  function(value) {
   // ... do stuff here when the select value is changed
}

Just add an onchange directive to your select element:

<label for="cab-pending-agenda-filter" class="sr-only">${Agenda list filter}</label>
<select 
id="cab-pending-agenda-filter" 
class="sn-select-basic expand" 
ng-model="selectedItem" 
   ng-change="selectChanged(selectedItem)"
ng-init="selectedItem = CAB.PENDING" 
ng-disabled="page.loading" 
tabindex="0">
          
            <option value="{{::CAB.PENDING}}">{{::c.data.i18n.filter[CAB.PENDING]}}</option>
            <option value="{{::CAB.ALL}}">{{::c.data.i18n.filter[CAB.ALL]}}</option>
            <option value="{{::CAB.MINE}}">{{::c.data.i18n.filter[CAB.MINE]}}</option>
            <option value="{{::CAB.APPROVED}}">{{::c.data.i18n.filter[CAB.APPROVED]}}</option>
            <option value="{{::CAB.COMPLETE}}">{{::c.data.i18n.filter[CAB.COMPLETE]}}</option>
        </select>

then define the assigned method in the $scope of the controller that contains the select box:

$scope.selectChanged =  function(value) {
   // ... do stuff here when the select value is changed
}
樱娆 2025-01-26 13:08:16

或者,如果您只想查看是否有任何事件分配给该元素,您可以:

  1. 打开 chrome devtools
  2. 检查“select”元素并确保在 devtools 的“Elements”选项卡中选择它
  3. 打开控制台抽屉(按 Esc)如果尚未
  4. 在控制台中打开输入类型:console.log($0.onchange)

如果先前已分配给元素 onchange 事件,则这将输出任何函数的内容。

Alternatively, if you just want to see if any event is assigned to the element you can:

  1. open chrome devtools
  2. inspect the 'select' element and make sure it is selected in the 'Elements' tab of devtools
  3. open the console drawer (pressing Esc) if not open already
  4. in the console input type: console.log($0.onchange)

This will output the contents of any function if assigned previously to the element onchange event.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文