1

This is module and controller code

var app = angular.module('apApp',[]);

app.controller('apCtrl', ['$scope','$http','getPopByBranch',function($scope, $http,getPopByBranch)
{   
    $scope.greeting = 'Hola!';

    console.log(getPopByBranch.test) ;                                                   

}]);

var boot_apApp = document.getElementById('apApp');

angular.element(document).ready(function() {
   angular.bootstrap(boot_apApp, ['apApp']);
});

This is my service code saved in separate js file

angular.module('apApp').factory('getPopByBranch', function($http){

var pops = {};
pops.test = function(){ return "Hello";};
//i want value of second function also
//pops.test = function foo(){ return "Bye";};
return pops;                               
});

output in console

function(){ return "Hello";}

The problem is that i want only hello or some value returned .

1 Answer 1

1

You need to call the function. Update from

console.log(getPopByBranch.test);  

to

console.log(getPopByBranch.test());  
Sign up to request clarification or add additional context in comments.

1 Comment

@MartijnWelker - That can be said only after looking at the markup. Additionally, I believe the OP is able to log the function then OP is able to bootstrap the application. It is just OP is missing on calling a function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.