我是第一次在Angular中建立SPA,但是我构建的app-video-controls组件存在问题。
我使用HTML对应用程序进行了原型设计,并且香草javascript很好用,但是当我在Angular中重建并导入相同的js文件时,我开始出现错误:
无法将属性'currentTime'设置为null
这是Profile.Component.html
<div class="Section1">
<button id="video1" class="video-btn playing">
<div class="icon"><i class="fas fa-play-circle"></i></div>
<div class="video-text"><strong>Section 1. Introduction and Warm up</strong><br>
</div>
</button>
<div id="timestamp-1" class="list">
<ul>
<li class="question"><button onclick="setCurTime()" type="button">What is your name?</button></li>
<li class="question"><button onclick="setCurTime2()" type="button">What do you study?</button></li>
<li class="question"><button onclick="setCurTime3()" type="button">How did you develop this interest in linguistics?</button></li>
<li class="question"><button onclick="setCurTime4()" type="button">What do you do for fun?</button></li>
</ul>
</div>
<button id="video2" class="video-btn ">
<div class="icon"><i class="fas fa-play-circle"></i></div>
<div class="video-text"><strong>Section 2. Academic Discussion</strong><br>
Discussion based on information provided</div>
</button>
<div id="timestamp-2" class="list inactive">
<ul>
<li class="question"><button onclick="setCurTime5()" type="button">Argument For Solar Energy</button></li>
<li class="question"><button onclick="setCurTime6()" type="button">Argument For Bike Paths</button></li>
<li class="question"><button onclick="setCurTime7()" type="button">What were the two ideas?</button></li>
<li class="question"><button onclick="setCurTime8()" type="button">Which idea should be implemented first?</button></li>
<li class="question"><button onclick="setCurTime9()" type="button">Safety concerns?</button></li>
</ul>
</div>
<button id="video-3" class="video-btn">
<div class="icon"><i class="fas fa-play-circle"></i></div>
<div class="video-text"><strong>Section 3. Academic Presentation</strong><br>
Questions based on an academic lecture</div></button>
<div id="timestamp-3" class="list inactive">
<ul>
<li class="question"><button onclick="setCurTime10()" type="button">Summarize the video you viewed on cave paintings.</button></li>
<li class="question"><button onclick="setCurTime11()" type="button">Have you ever taken an art class?</button></li>
<li class="question"><button onclick="setCurTime12()" type="button">Do you think there should be more art classes in primary schools?</button></li>
</ul>
</div>
<button id="video-4" class="video-btn"> <div class="icon"><i class="fas fa-play-circle"></i></div>
<div class="video-text"><strong>Section 4. Free Discussion</strong><br>
Interviewee talks about any topic they like</div> </button>
<div id="timestamp-4" class="list inactive">
<ul>
<li class="question"><button onclick="setCurTime13()" type="button">Experience living in a foreign country</button></li>
<li class="question"><button onclick="setCurTime11()" type="button">What did you notice about different cultures living abroad?</button></li>
</ul>
</div>
</div>
在此处显示video-controls.component.html
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"src/app/js/video.js"
],
angular.json文件的片段
var vid = document.getElementById("my-video");
function getCurTime() {
alert(vid.currentTime);
}
function setCurTime() {
vid.currentTime=14;
}
最后是js的片段
Datatable dt; // that is the source datatable
DataView SortedDataView = new DataView();
SortedDataView = dt.DefaultView;
SortedDataView.Sort = "COlumnNameToSortBy DESC";
dt = SortedDataView.ToTable();