Search code examples
angularjsangular-moment

how do i add angular-moment filter here?


Am new to angularjs and given a codebase to add angular-moment (moments.js) to a module.

The module is defined is as follows:

angular.module("xyz", ["ngRoute",
                              "ui.bootstrap",
                              "infinite-scroll",
                              "uiGmapgoogle-maps",
                              "googlechart"],          
     function($interpolateProvider) {
        $interpolateProvider.startSymbol("[[");
        $interpolateProvider.endSymbol("]]");
})
    .factory("principal", principal)
    .factory("authorization", authorization)
    .factory("pingService", abc)

When i add angularMoment just after "googlechart" i get a "unpr" angular error. I did include both moments.js and angular-moments.js in my html.

I need to use javascript moments lib in my angular code.

Please help.

thanks


Solution

  • You haven't included 'angularMoment' in your module as dependency. Do like following :

    angular.module("xyz", ["ngRoute",
                                  "ui.bootstrap",
                                  "infinite-scroll",
                                  "uiGmapgoogle-maps",
                                  "googlechart","angularMoment"],          
         function($interpolateProvider) {
            $interpolateProvider.startSymbol("[[");
            $interpolateProvider.endSymbol("]]");
    })
        .factory("principal", principal)
        .factory("authorization", authorization)
        .factory("pingService", abc)
    

    And make sure , you have included the angular-moment.js file in your index.html

    I hope this helps. Do let me know in case of any query