【发布时间】:2019-02-10 11:30:23
【问题描述】:
我已经用 angular 编写了服务。在浏览器控制台中,数据即将到来,但作为回报,我没有得到 [object Object];
/// <reference path="angular.min.js" />
var app = angular.module("myapp", []);
app.service("myservice", function ($http) {
this.myfun = function () {
var x;
$http.get("http://localhost:41173/api/AngularTest/login_valid").success(function (response) {
console.log("all get data",response);
x = response.data
}).error(function (err) {
console.log("all error ", err);
});
debugger;
return x;
}
});
app.controller("myctrl", function ($scope, $http, myservice) {
$scope.transform = function (input) {
$http.get("http://localhost:41173/api/AngularTest/login_valid").then(function (response) {
if (response.data == true) {
$scope.out = myservice.myfun();
}
else {
$scope.out = "Fail";
}
});
}
});
【问题讨论】:
标签: angularjs asp.net-mvc asp.net-web-api