将MINUTES放在Progress元素的Max属性中

问题描述 投票:1回答:1

所以我有一个songDuration变量:

例如:

this.songDuration = 4:20

我使用角度4,所以我使用插值输入值

<progress value="{{songTime}}" max="{{songDuration}}"></progress>

当我这样做时,我在控制台中收到错误消息“提供的double值是非限定的”。

如何将此变量转换为与max属性兼容的值?

angular audio progress
1个回答
1
投票

试试这个

convert(input) {
    var parts = input.split(':'),
    minutes = +parts[0],
    seconds = +parts[1];
    return (minutes * 60 + seconds).toFixed(3);
}

然后

this.songDuration = this.convert('4:20');
this.songTime = this.convert('<something else>');

(评论是否有任何问题)

© www.soinside.com 2019 - 2024. All rights reserved.