gpt4 book ai didi

javascript - 创建一个指令以使 ng-keyup 成为备用搜索初始值设定项

转载 作者:行者123 更新时间:2023-12-03 07:42:23 25 4
gpt4 key购买 nike

我是 Angular 新手,我有几个文本字段、一个复选框和一个下拉菜单,我该如何制作才能按下 Enter 按钮并提交?我一直在阅读并找到了 ng-submit 函数,我将其放入我的表单中,但没有任何反应,我假设我必须在我的 Angular Controller 中的某个位置激活它。

 <form ng-submit="search()">
<div class="form-group">
<label>Job Number</label>
<input class="form-control" style="width: 92%" type="text" ng-model="jobNumber"/>
</div>
</form>
<form ng-submit="search()">
<div class="form-group">
<label>Description</label>
<input class="form-control" style="width: 92%" type="text" ng-model="description" />
</div>
</form>
</div>
</div>

我没有在下面的 Controller 中执行任何操作。

var CapitalRequestMultiMillInquiryController = function ($scope, $sce, $rootScope, $modal, $window, CapitalRequestService, PlantService) {


$rootScope.title = 'Capital Request Multi Mill Inquiry';
$scope.allMills = [];
$scope.mill = '';
$scope.jobNumber = '';
$scope.description = '';
$scope.amount = '';
$scope.amountOperator = '';
$scope.openOnly = '';
$scope.projectManager = '';

//$scope.allUsers = [];

//UsersService.getUsersWithId().then(function(objectTypes) {
// $scope.allUsers = objectTypes
//});

//CapitalRequestService.searchMulti("http://tomcmmsweb.pca.com/CapitalRequest/Search", authenticatedUser.userName.toUpperCase(), $scope.selectedMill, $scope.jobNumber, $scope.description, $scope.amount, $scope.amountOperator, $scope.openOnly, $scope.projectManager).then(function (results) {
// $scope.tomahawk = results;
// for (var i = 0; i < $scope.tomahawk.length; i++)
// $scope.tomahawk[i] = $sce.trustAsHTML($scope.tomahawk[i]);
//});


PlantService.getPlantId().then(function (mills) {
$scope.allMills = mills
});

$scope.search = function() {
//for each mill

CapitalRequestService.searchMulti("http://coucmmsweb.pca.com/CapitalRequest/Search", authenticatedUser.userName.toUpperCase(), $scope.mill, $scope.jobNumber, $scope.description, $scope.amount, $scope.amountOperator, $scope.openOnly, $scope.projectManager).then(function (results) {
$scope.counce = results;
$scope.counce.forEach(function (item) {
// item.projectManager = $sce.trustAsHtml(item.projectManager);
item.jobNumber = $sce.trustAsHtml(item.jobNumber);
item.description = $sce.trustAsHtml(item.description);
item.amount = $sce.trustAsHtml(item.amount);
});
});

CapitalRequestService.searchMulti("http://filcmmsweb.pca.com/CapitalRequest/Search", authenticatedUser.userName.toUpperCase(), $scope.mill, $scope.jobNumber, $scope.description, $scope.amount, $scope.amountOperator, $scope.openOnly, $scope.projectManager).then(function (results) {
$scope.filer = results;
$scope.filer.forEach(function (item) {
// item.projectManager = $sce.trustAsHtml(item.projectManager);
item.jobNumber = $sce.trustAsHtml(item.jobNumber);
item.description = $sce.trustAsHtml(item.description);
item.amount = $sce.trustAsHtml(item.amount);
});
});

CapitalRequestService.searchMulti("http://tomcmmsweb.pca.com/CapitalRequest/Search", authenticatedUser.userName.toUpperCase(), $scope.mill, $scope.jobNumber, $scope.description, $scope.amount, $scope.amountOperator, $scope.openOnly, $scope.projectManager).then(function (results) {
$scope.tomahawk = results;
$scope.tomahawk.forEach(function (item) {
// item.projectManager = $sce.trustAsHtml(item.projectManager);
item.jobNumber = $sce.trustAsHtml(item.jobNumber);
item.description = $sce.trustAsHtml(item.description);
item.amount = $sce.trustAsHtml(item.amount);
});
});

CapitalRequestService.searchMulti("http://tridentval.pca.com/api/Inquiry/Inquiry/CapitalRequestMultiMillInquiry/Search", authenticatedUser.userName.toUpperCase(), $scope.mill, $scope.jobNumber, $scope.description, $scope.amount, $scope.amountOperator, $scope.openOnly, $scope.projectManager).then(function (results) {
$scope.valdosta = results;
});

CapitalRequestService.searchMulti("http://tridentder.pca.com/api/Inquiry/Inquiry/CapitalRequestMultiMillInquiry/Search", authenticatedUser.userName.toUpperCase(), $scope.mill, $scope.jobNumber, $scope.description, $scope.amount, $scope.amountOperator, $scope.openOnly, $scope.projectManager).then(function (results) {
$scope.deridder = results;
});

CapitalRequestService.searchMulti("http://valcmmsweb.pca.com/CapitalRequest/Search", authenticatedUser.userName.toUpperCase(), $scope.mill, $scope.jobNumber, $scope.description, $scope.amount, $scope.amountOperator, $scope.openOnly, $scope.projectManager).then(function (results) {
$scope.whiteMills = results;
$scope.whiteMills.forEach(function (item) {
item.jobNumber = $sce.trustAsHtml(item.jobNumber);
item.description = $sce.trustAsHtml(item.description);
item.amount = $sce.trustAsHtml(item.amount);
});
});

}
};

最佳答案

我相信这个问题已经在这里得到解答: Submit form on pressing Enter with AngularJS

如果这不能涵盖它,请告诉我。

关于javascript - 创建一个指令以使 ng-keyup 成为备用搜索初始值设定项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35350981/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com