1
在ng-click調用publishBookmark作用域對象。在html頁面上渲染它有一個視頻標籤,因此抓住視頻標籤並嘗試獲取當前時間位置該按鈕但總是獲得「0」作爲警報消息。如何通過ng-click獲取視頻對象的時間
<button class="btn-default" type="button" data-ng-click="publishBookmark()">
</button>
$scope.publishBookmark = function() {
var location = document.getElementsByTagName("video").currentTime;
alert(location);
};
<!--Videogular COntainer Starts -->
<div ng-controller="videogularController as controller" class="videogular- player">
<videogular vg-theme="controller.config.theme.url"
vg-auto-play="controller.config.plugins.controls.autoPlay">
<vg-media vg-src="controller.config.sources"
vg-native-controls="false">
</vg-media>
<vg-controls vg-autohide="controller.config.plugins.controls.autoHide"
vg-autohide-time="controller.config.plugins.controls.autoHideTime">
<vg-play-pause-button></vg-play-pause-button>
<vg-time-display>{{ API.currentTime | date:'mm:ss':'+0000' }}</vg-time- display>
<vg-scrub-bar>
<vg-scrub-bar-current-time></vg-scrub-bar-current-time>
</vg-scrub-bar>
<vg-time-display>{{ API.totalTime | date:'mm:ss':'+0000' }}</vg-time-display>
<vg-volume>
<vg-mute-button></vg-mute-button>
<vg-volume-bar></vg-volume-bar>
</vg-volume>
<vg-playback-button></vg-playback-button>
<vg-fullscreen-button></vg-fullscreen-button>
</vg-controls>
<vg-poster vg-url='controller.config.plugins.poster'></vg-poster>
</videogular>
<!-- Videogular Container Ends -->
警報始終顯示0爲默認值。 新角JS,需要幫助。 謝謝。
您的html也可以是有用的。 –
@ Pierre-Alexandre Moller - 已添加html部分。 –
這可能會有所幫助 - http://jsfiddle.net/B7hT5/ –