Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
136
rated 0 times [  138] [ 2]  / answers: 1 / hits: 39185  / 9 Years ago, fri, may 8, 2015, 12:00:00

I have difficulties understanding this error... I dont quite understand why its not a function....



angular.module('mkApp').factory('mkService', function ($http, $log) {
function getLookUp(successcb) {
$http = ({
method: 'GET',
url: 'api/Entries/'

}).success(function (data, status, header, config) {
successcb(data);
}).
error(function (data, status, header, config) {
$log, warn(data, status, header, config);
});
};

return {
lookUp: getLookUp
}
});

angular.module('mkApp').controller('mkControler', function ($scope, mkService) {
mkService.lookUp(function (data) {
$scope.ddl = data;
console.log(ddl);

});
});


And here is my HTML



<div ng-app=mkApp>
<div ng-controller=mkControler>
<table>
<tr>
<td> First Name</td>
<td> Last Name</td>
</tr>
<tr>
<td><input type=text /></td>
<td><input type=text /></td>
</tr>
<tr>
<td>
<select></select>
</td>
</tr>
</table>

</div>
</div>


My idea is to use data to populate drop down. It does bring me XML back.
Any help please i've been looking everywhere now.
Thank you.


More From » angularjs

 Answers
36

Your $http call code should be $http({ instead of $http = ({ and also $log, warn should be $log.warn



Code



$http({
method: 'GET',
url: 'api/Entries/'
}).success(function (data, status, header, config) {
successcb(data);
}).
error(function (data, status, header, config) {
$log.warn(data, status, header, config);
});

[#66674] Thursday, May 7, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ignacio

Total Points: 467
Total Questions: 128
Total Answers: 79

Location: Luxembourg
Member since Tue, Mar 14, 2023
1 Year ago
ignacio questions
;