javascript - Loading Module in AngularJS Service -
i'm learning angularjs. currently, i'm trying load third-party module in service. specifically, i'm trying load angular-moment
. service defined this:
myapp.factory('myservice', ['angularmoment', function(angularmoment) { return { getlocale: function() { return angularmoment.locale(); } } }]);
if replace return angularmoment.locale()
return 'somelocale';
code runs. however, reference angularmoment
, errors. know has fact i'm not loading module correctly. however, not know i'm doing wrong. see error when run unit tests:
error: [$injector:unpr] http://errors.angularjs.org/1.2.22/$injector/unpr?p0=angularmomentprovider%20%3c-%20angularmoment%20%3c-myservice (line 36) (1)
what doing wrong?
try 'moment' instead of angularmoment in service/factor injector. give object momentjs
myapp.factory('myservice', ['moment', function(moment) { return { getlocale: function() { return moment.locale(); } } }]);
Comments
Post a Comment