Exposing functions in js service format: Will this work?

44 views Asked by At

Will this work?

Service.js

(function() {
    var module = angular.module('myApp');

    var myService = function () { 

        var myServiceMethod = function () { //some code };

        return factory;
    };

    var module = angular.module('blueBoxApp');
    module.factory('myService', myService);
}())

Controller.js

(function() {
    var module = angular.module('myApp');

    var myController = function (myService) { 

        myService.myServiceMethod();
    };

    module.Controller('myController', myController);
}())

Right now, in my service, I am returning an object containing the names of each service. Can I just return the factory and have access to them? Or do I have to prefix each service method with thisFactoryObj?

0

There are 0 answers