Can I have multiple functions in my AngularJS Factory? -


I am following the official AngularJS docs and I want to know if I can add another function to the phone factory I can arrange better code, they have announced a "query" function, but if I want to add a query 2 function which refers to a different URL ... say phone 2 /: phoneName. Json for example?

Factory announcement:

  var phonecat services = angular Modules ('Phonecat Services', ['NgrSource']); PhonecatServices.factory ('phone', ['$ resource', function ($ resource) {return $ resource ('phone /: phoneId.json', {}, {query: {method: 'GET', parameter: {phoneId : 'Phone'}, IARRA: true}});}]);   

I have tried many things and none of them are working: s

This is on the right track, but the syntax for every factory

  phonecatServices.factory ('phone', ['$ resource', function]   ($ resource) {return {query} ... query2: ...} }];    

An example of this is:

  factory ('Factory name', ["$ filter", function ($ filter) {var method1 logic = function (args) {// code}; var method2Logic = function (args) controller ('mancontroller', ["$ scope" , "$ RootScope", "$ filter", "factoryname", function ($$), {$ code} $ Scope.testMethod1 = function (arg) {$ scope.val1 = factoryName.method1 (arg);}; $ Scope.testMethod2 = function (arg) {$ scope.val2 = FactoryName.method2 (arg);}}}]);   

There is also a better version of this:

  function other service () {var AnotherService = {}; another Some value = ''; another service. Some method = function () {}; another service back;} angular module ('app'). Faster ('other service', other service);    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -