如何在Angualar的jqLit​​e元素对象中按id查找元素

nav*_*ngh 2 javascript angularjs jqlite

我正在使用这个:

$vehicleTypeDropdown = element.find(".vehicleTypeDropdown");

然后在以后的时间点我想找到#pselectID元素.我$vehicleTypeDropdown看起来像这是jqLit​​e对象: -

<select class="vehicleTypeDropdown" id="vehicleType">
<option id="#pselect" value="">Please Select</option>
<option ng-repeat="types in selectedType" value="Vt3" class="ng-scope ng-binding">vt3</option>
<option ng-repeat="types in selectedType" value="Vt4" class="ng-scope ng-binding">vt4</option>
</select>
Run Code Online (Sandbox Code Playgroud)

有两个问题 -

  1. 它是在jqLit​​e文档中编写的,该.find()方法只查找标记,而不是类或id.那我怎么得到

    $vehicleTypeDropdown = element.find(".vehicleTypeDropdown");

    作为jqLite内容的对象?

  2. 我怎样才能找到该选项#pselect?我想手动删除它,请记住它可以在选项中以任何顺序.

vor*_*ant 5

使用id不#喜欢id="pselect"

<select class="vehicleTypeDropdown" id="vehicleType">
    <option id="pselect" value="">Please Select</option>
    <option ng-repeat="types in selectedType" value="Vt3" class="ng-scope ng-binding">vt3</option>
    <option ng-repeat="types in selectedType" value="Vt4" class="ng-scope ng-binding">vt4</option>
</select>
Run Code Online (Sandbox Code Playgroud)

捕捉这样的元素

var elem = angular.element(document.querySelector('#pselect'))
elem.remove()
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/vorant/4sbux96k/1/