angularjs-xeditable整合typeahead完成智能提示
按照需求,需要在angularjs的xeditable中加入typeahead,来完成智能提示,并且在选择后,把该条数据的其他信息也显示在此行中,于是做了一下的测试修改。
当然,既然用了xeditable肯定就需要加入这个模块。
var Myapp = angular.module('Myapp ',['xeditable']);
下面是页面上的html代码
<div ng-controller="productController">
<table class="table table-bordered table-condensed">
<tr style="font-weight: bold">
<td style="width:10%">类型</td>
<td style="width:20%">名称</td> <td style="width:25%">Edit</td>
</tr>
<tr ng-repeat="product in products">
<td>
<span editable-text="product.type" e-name="type" e-form="rowform"
e-uib-typeahead="products.type for products in products | filter:$viewValue | limitTo:8"
e-typeahead-on-select="getProductDetail($item, $model)"
>
{{ product.type || 'empty' }}
</span>
</td>
<td>
<span editable-text="product.name" e-name="name" e-form="rowform" >
{{ product.name || 'empty' }}
</span>
</td> <td style="white-space: nowrap">
<form editable-form name="rowform" onbeforesave="saveProduct($data,product.id)" ng-show="rowform.$visible" class="form-buttons form-inline" shown="inserted == product">
<button type="submit" ng-disabled="rowform.$waiting" class="btn btn-primary">
save
</button>
<button type="button" ng-disabled="rowform.$waiting" ng-click="rowform.$cancel()" class="btn btn-default">
cancel
</button>
</form>
<div class="buttons" ng-show="!rowform.$visible">
<button class="btn btn-primary" ng-click="rowform.$show()">edit</button>
<button class="btn btn-danger" ng-click="removeProduct($index,product)">del</button>
</div>
</td>
</tr>
</table>
<button class="btn btn-default" ng-click="addProduc()">Add row</button>
</div>
Js代码
//因为暂时未能解决$http的同步问题,所以只能取出所有数据,然后在匹配
$http.get("selectAllProduct")
.success(function(data){
$scope.products=data;
})
/*var xmlHttp;
此方法虽然能实现,但是页面数据有问题
使用原生的XMLHttpRequest同步获取数据
function createXMLHttpRequest(){
if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}else if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
$scope.getProducts=function(type){
createXMLHttpRequest();
if(xmlHttp!=null){
xmlHttp.open("GET","selectProductByType/"+type,false);
xmlHttp.send(null);
}
console.log(xmlHttp.responseText);
return xmlHttp.responseText; }*/
//获取产品详细信息
$scope.getProductDetail = function ($item, $model) {
$scope.inserted = {
type: $model
name: $item.name,
}
$scope.products[$scope.products.length-1]=$scope.inserted;
};
//保存产品
$scope.saveProduct= function(data,id) {
angular.extend(data, {id: id});
return $http.post('saveProduct', data);
};
//添加行
$scope.addProduct = function() { $scope.inserted = {
type: '',
name:''
};
$scope.esms.push($scope.inserted);
}
//删除行
$scope.removeProduct = function(index,product) {
if (confirm("你确定删除此行?")){
$http.get("delete"+product.id)
.success(function(data){
$scope.products.splice(index, 1);
})
}
};
小结:
关于如何使用$http完成同步获取数据的问题目前暂时未能解决
angularjs-xeditable整合typeahead完成智能提示的更多相关文章
- 五小步让VS Code支持AngularJS智能提示
本文想通过配置VS Code来实现对AngularJS的智能提示.在一般的情况下对于在HTML页面是支持提示的.但是在js页面就不是很友好,它是记忆你之前的输入,要是之后有重复的输入,VS Code会 ...
- angular-ui-bootstrap typeahead 智能提示 自动补全 获取焦点不触发问题的解决
项目中有一处使用了angular-ui-bootstrap中的typeahead来实现输入框智能提示语自动化补全的功能,存在一个bug, 即输入文字后,当再次点击文本框,其获取焦点后并不会触发智能提示 ...
- 在ASP.NET MVC中使用typeahead.js支持预先输入,即智能提示
使用typeahead.js可以实现预先输入,即智能提示,本篇在ASP.NET MVC下实现.实现效果如下: 首先是有关城市的模型. public class City { public int Id ...
- Visual Studio Code 智能提示文件
Visual Studio Code 开发前端和node智能提示 visual studio code 是一个很好的编辑器,可以用来编写前端代码和nodejs. 我很喜欢使用VSC,现在流行框架对VS ...
- VS2013中实现angular代码智能提示
第一步:在项目同添加angular js文件的引用: 这里使用NuGet包管理器来给项目添加angular js install-package angularjs 第二步:添加智能提示js文件 我们 ...
- ExtJS ComboBox 录入智能提示
ExtJS ComboBox非常复杂,有很多的属性:其中有的属性是针对某一种特定的方案而设计的,不是所有情况下都有效.我想下拉选择能支持录入,并且录入时能智能提示,弄了半天可以了,但是只能是mode= ...
- Eclipse代码和xml文件的智能提示
一.代码智能提示 Windows → Preferences → Java→ Editor → Content Assist 将 Auto activation delay(ms): 改为 0 将 A ...
- Laravel 安装代码智能提示扩展「laravel-ide-helper」
========================laravel-ide-helper======================== 使用 Laravel 框架IDE居然没有智能提示?这感觉实在太糟糕 ...
- 利用typescript使backbone强类型智能提示
模型类一旦多了没有强类型和智能提示是相当痛苦的,所以. 仅仅用ts定义一个模型类: class Person extends Backbone.Model { defaults = { Name:&q ...
随机推荐
- linux 编程技术
linux 编程技术No.1前期准备工作 GCC的编译过程分为预处理.生成汇编代码.生成目标代码和链接成可执行文件等4个步骤. 使用vim编写C 文件 : [lining@localhost prog ...
- JavaScript模板引擎原理
JavaScript模板引擎原理,几行代码的事儿 2013-12-03 16:35 by BarretLee, 650 阅读, 6 评论, 收藏, 编辑 一.前言 什么是模板引擎,说的简单点,就是一个 ...
- Power Designer导出实体类和NHibernate xml文件
Power Designer导出实体类和NHibernate xml文件 今天研究了一下通过PowerDesigner生成实体类和NHibernate所需要的xml文件,方法是通过Power Desi ...
- [原]逆向iOS SDK -- “添加本地通知”的流程分析
观点: 代码面前没有秘密 添加通知的 Demo 代码 - (void)scheduleOneLocalNotification { [[UIApplication sharedApplication] ...
- MongoDB集群与LBS应用系列(一)
MongoDB集群与LBS应用系列(一) 1. 概念 MongoDB作为著名的NoSQL,早已非常流行.它的地理应用也非常成熟,被foursquare用于生产环境也已经多时.本文主要记录今年6月份的一 ...
- Mobile页面项目总结
项目过去个把月了,一直没有写些东西总结下,这次借着年后的空隙,将当时记录下来的几个点回顾一下. 今明的布局:position技巧 每当看到类似横向并排布局的时候,总是想起定宽浮动,和下面讲到的列表并排 ...
- XML中的五个保留字符及实体引用
字符名称 字符 实体引用 和 & & 大于号 > > 小于号 < < 单引号 ‘ ' 双引号 “ " 在XML文档中,构成元素内 ...
- GC算法精解(五分钟教你终极算法---分代搜集算法)
GC算法精解(五分钟教你终极算法---分代搜集算法) 引言 何为终极算法? 其实就是现在的JVM采用的算法,并非真正的终极.说不定若干年以后,还会有新的终极算法,而且几乎是一定会有,因为LZ相信高人们 ...
- K2 BPM项目 基于COM组件调用SAP RFC 问题
K2 BPM项目 基于COM组件调用SAP RFC 问题 问题前景: 环境:Win 2008 R2 64bit 最近项目中有支流程需求中需要在会计入账环节回写SAP的会计凭证. SAP组给我们提供.N ...
- Linux并发模型
Linux并发模型 Linux并发模型 目前可以实现并发程序的方法有Apache模型(Process Per Connection,简称PPC),TPC(Thread PerConnection)模型 ...