Click here to Skip to main content
15,921,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
var app =angular.module('myapp',[]);

JS1.js
-------

app.factory('Servicename',function($http){

function method1()
{}
function method2()
{}

})

JS2.js
------

app.factory('Servicename',function($http){

function method3()
{}

function method4()
{}

})
Posted
Comments
Sergey Alexandrovich Kryukov 2-Apr-15 19:33pm    
First of all, there are no classes in JavaScript. Also, having separate files is not essential in JavaScript; it can be good for convenience, but provides no isolation at all. If you include several files in HTML, they just are processes one after another, without any boundaries. Still, there can be some merit in your idea. I see no problem in implementing the factory functions this way, but I just don't know how is it actually implemented in AngularJS. I would do it... :-)
—SA

JS1.js
----------------
app.factory("Servicename",function($http){

function method1()
{}
function method2()
{}


JS2.js
--------
app.factory("Servicename1",function($http){

function method3()
{}

function method4()
{}

})

1.mandatorly Declare factories with different names under same module
 
Share this answer
 
by specifying different factory names in separate js files
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900