创建一个指令以使 ng-keyup 成为备用搜索初始值设定项
creating a directive to make ng-keyup be an alternate search initializer
我是 angular 的新手,我有几个文本字段、一个复选框和一个下拉菜单,我怎样才能按下 Enter 按钮,它会提交? 我一直在阅读并找到了 ng-submit 函数,我将其放在我的表单中,但没有任何反应 我假设我将不得不在我的 angular 控制器中的某个地方激活它。
<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>
我没有在下面的控制器中做任何事情。
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);
});
});
}
};
我相信这里已经回答了:使用AngularJS按回车键提交表格
如果这还不包括它,请告诉我。
相关文章:
- 用程序搜索JQuery数据表中的文本
- 在html Select中添加搜索
- Ajax Live搜索发布到Laravel视图
- 谷歌放置API:按国家或餐馆名称搜索餐馆
- 学生搜索项目jquery/javascript
- 用于搜索的聚合物嵌套绑定
- 在javascript中搜索具有重复值的两个数组中的匹配值
- Angularjs-utils高亮过滤器在搜索时破坏应用程序
- 使用javascript搜索具有用户输入的数组
- 淘汰搜索/筛选
- 搜索api在mac上显示对话框
- AngularJS/HTML/Bootstrap元素用于动态搜索结果
- 谷歌水印未显示在自定义搜索框中
- 在javascript中搜索项目列表的性能
- 正在搜索JavaScript日期选择器滑块
- JQuery中的活动搜索栏
- 如何在剑道下拉列表中按文本和值搜索
- 谷歌CSE-搜索参数
- 如何让typeahead在我的搜索栏中填充自定义参数
- 创建一个指令以使 ng-keyup 成为备用搜索初始值设定项