我想从html代码中获取所有唯一的YouTube视频ID
查看youtube视频的(或多个)对象/嵌入代码
//来自数据库的html
<p>loremm ipsum dolor sit amet enot
<a href="link" attribute=""blah blah blah">anchor link</a>
</p>
<object width="425" height="344">
<param name="movie" value="http://www.youtube.com/v/Ou5eVl5eqtg&hl=es_ES&fs=1&"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/Ou5eVl5eqtg&hl=es_ES&fs=1&"
type="application/x-shockwave-flash"
allowscriptaccess="always"
allowfullscreen="true"
width="425"
height="344">
</embed>
</object>
<image src="path/to/image.ext" >
<p>lorem ipsum dolor sit amet... blah</p>
<p>lorem ipsum dolor sit amet... blah</p>
<object width="425" height="344">
<param name="movie" value="http://www.youtube.com/v/Ou5eVl5eqtg&hl=es_ES&fs=1&"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/Ou5eVl5eqtg&hl=es_ES&fs=1&"
type="application/x-shockwave-flash"
allowscriptaccess="always"
allowfullscreen="true"
width="425"
height="344">
</embed>
</object>
<p>blah</p>
blah<br/>
blah<br/>
blah<br/>
Run Code Online (Sandbox Code Playgroud) 我想要做的是通过输入值过滤数字/字符串项的数组.我的代码是这样的.
如果$ scope.groups [#].number是一个对象数组,则过滤器搜索对象的属性.但是我希望在$ index跟踪的情况下过滤我的简单值的简单数组.
那可能吗?对此有何解决方法?或者我还需要使用一个对象数组.
这里有一个关于jsfiddle的例子http://jsfiddle.net/u9y9h/3/
HTML:
<div ng-app>
<div ng-controller="repeater">
<input placeholder="number" type="text" ng-model="number">
<input type="button" ng-click="addItem()" value="Add item"><br>
<input placeholder="query" type="text" ng-model="query">
<div ng-repeat="group in groups">
<h3>{{group.title}}</h3>
<ul>
<li ng-repeat="item in group.numbers track by $index | filter:query">{{item}}</li>
</ul>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
JS:
function repeater($scope) {
$scope.items = [];
$scope.groups = [{
title: 'even',
numbers: []
}, {
title: 'odd',
numbers: []
}];
$scope.addItem = function () {
if ($scope.number % 2 == 0) {
$scope.groups[0].numbers.push($scope.number);
} …Run Code Online (Sandbox Code Playgroud)