javascript - TypeError: (intermediate value)(intermediate value).success is not a function (angular) -
i have difficulties understanding error... dont quite understand why not 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 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 use data populate drop down. bring me xml back. please i've been looking everywhere now. thank you.
your $http
call code should $http({
instead of $http = ({
, $log, warn
should $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); });
Comments
Post a Comment