我很难理解这个错误...我不太明白为什么它不是一个函数……
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);
});
});这是我的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>我的想法是使用数据填充下拉列表。它确实给我带来了XML。有什么可以帮我的吗?我现在到处找。谢谢。
发布于 2015-05-08 22:56:59
您的$http调用代码应该是$http({而不是$http = ({,并且$log, warn应该是$log.warn
代码
$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);
});https://stackoverflow.com/questions/30126612
复制相似问题