Using the plug-in format for the length of time inside the Angular controller

I am trying to use the moment-duration-format plugin to format the duration of MomentJS. How can I use this plugin in my Angular controllers? It looks like it should work out of the box after JS has been imported, but it is not.

I imported the instant JS and MDF JS file into my index.html:

// 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>

But when I call the bottom line in the controller, I get an error message:

console.log( moment.duration(123, "minutes").format("h:mm") );

Error:

TypeError: moment.duration(...).format is not a function...
+4
source share
1 answer

Include your lib file at the time of your application, for example, in the file file added to the file section, and then you just need to call it as

console.log ("moment →", moment ());

0
source

Source: https://habr.com/ru/post/1588901/


All Articles