提问人:user199135 提问时间:11/23/2021 最后编辑:Kinglishuser199135 更新时间:11/23/2021 访问量:39
结束 AngularJS 连接
Ending an AngularJS connection
问:
我到底如何使用 AngularJS 做到这一点?
我正在使用此代码生成带有搜索栏的客户端表。ASP.NET MVC 是这里的服务器。
app.controller('GenTable', ['$http' ,'$scope', '$window',
function($http ,$scope, $window)
{
console.log("I'm called");
$scope.CallSearch = function()
{
if($scope.SearchField==null)
{
$http.get("https://localhost:(portnumberhere)/project/all").then(function(response)
{
$window.Project = response.data;
ProjectLength = Project.length;
console.log("I'm in get");
});
}
else
{
PostData="";
PostData=$scope.SearchField;
$http.post("https://localhost:(portnumberhere)/project/filter",PostData).then(function(response)
{
$window.Project = response.data;
ProjectLength = Project.length;
console.log("I'm in post with"+PostData);
});
PostData="";
console.log("I'm not in post with PostData as "+PostData);
}
}
$http.get("https://localhost:(portnumberhere)/project/all").then(function(response)
{
$window.Project = response.data;
$scope.Project = $window.Project;
ProjectLength = Project.length;
console.log("I'm in get table");
});
console.log("I'm at end");
}]);
它打印在我的控制台中
I'm called
I'm at end
I'm in get table
这会瘫痪任何其他请求,例如使用搜索栏。
答: 暂无答案
评论
console.log('Im called')
$http.post
PostData={searchTerm: $scope.SearchField}