angular-requirejs-seed icon indicating copy to clipboard operation
angular-requirejs-seed copied to clipboard

How do I make sub-services into a service folder

Open festum opened this issue 12 years ago • 3 comments

Hello Tom,

I'm currently using your seed as my project starter and happy with that but I have a problem- the services and directives didn't split into folders and I've tried to do it but failed.

hope you could give me some help. thanks!

festum avatar Aug 28 '13 10:08 festum

@Festum I do it like this:

services/taskStorageSvc.js

define([], function () {
    return function () {
        return {
            /**
             * @return {Object}
             */
            get: function () {
                return //code
            },
            /**
             * @param {Object} task
             */
            put: function (task) {
                //code
            }
        }
    }

});

services.js

define([
    'angular',
    'services/taskStorageSvc'
], function (angular, taskStorageSvc) {
    return angular.module('dothis.services', [])
       .factory('taskStorage', taskStorageSvc);
});

finico avatar Mar 16 '14 20:03 finico

@finico Hello, your answer helps, but I have another problem, could you please help me out ?

I want to pass a dependency into the sub-service, for example:

define([], function (**DEPENDENCY_HERE**) {
    return function () {
        return {
            /**
             * @return {Object}
             */
            get: function () {
                return //code
            },
            /**
             * @param {Object} task
             */
            put: function (task) {
                //code
            }
        }
    }

});

How can I do such kind of thing ? Many thanks in advance !

destiny1020 avatar Aug 19 '14 12:08 destiny1020

@destiny1020 What kind of dependencies you are talking about ? Angular services, filters, directives or JavaScript files ?

SaidTayebi avatar Jun 16 '15 07:06 SaidTayebi