私はangularjsサービス内に関数を書きたいのですが、それをすべてのサービスで再利用したいです。
コントローラー。
var mod= angular.module('myapp', ['eventFilters', 'highlight', 'event', 'dayfilter', 'Services']).
config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/', {templateUrl: 'template.html', controller: Ctrl}).
when('/temp', {templateUrl: 'temp.html', controller: tempCtrl}).
otherwise({redirectTo: '/invalid'});
}]);
mod.service ('sharedService', function() {
function daysInMonth(month,year) {
return new Date(year, month+1,0).getDate();
}
});
コントローラーのいずれかでdaysInMonth関数を使用したい。出来ますか?もしそうなら、誰かがフィドルのいくつかの例で私を簡単に説明できますか?
前もって感謝します