Ale*_*exG 5 javascript angularjs momentjs
我正在尝试使用moment-duration-format插件格式化MomentJS持续时间。我将如何在Angular控制器中使用此插件?似乎一旦导入JS,它就应该开箱即用,但事实并非如此。
我已经在index.html中导入了momentJS和MDF JS文件:
// MomentJS
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.3/moment.min.js"></script>
// moment-duration-format plugin
<script src="bower_components/moment-duration-format/lib/moment-duration-format.js"></script>
Run Code Online (Sandbox Code Playgroud)
但是,当我在控制器中调用以下行时,出现错误:
console.log( moment.duration(123, "minutes").format("h:mm") );
Run Code Online (Sandbox Code Playgroud)
错误:
TypeError: moment.duration(...).format is not a function...
Run Code Online (Sandbox Code Playgroud)