按照需求,需要在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完成智能提示的更多相关文章

  1. 五小步让VS Code支持AngularJS智能提示

    本文想通过配置VS Code来实现对AngularJS的智能提示.在一般的情况下对于在HTML页面是支持提示的.但是在js页面就不是很友好,它是记忆你之前的输入,要是之后有重复的输入,VS Code会 ...

  2. angular-ui-bootstrap typeahead 智能提示 自动补全 获取焦点不触发问题的解决

    项目中有一处使用了angular-ui-bootstrap中的typeahead来实现输入框智能提示语自动化补全的功能,存在一个bug, 即输入文字后,当再次点击文本框,其获取焦点后并不会触发智能提示 ...

  3. 在ASP.NET MVC中使用typeahead.js支持预先输入,即智能提示

    使用typeahead.js可以实现预先输入,即智能提示,本篇在ASP.NET MVC下实现.实现效果如下: 首先是有关城市的模型. public class City { public int Id ...

  4. Visual Studio Code 智能提示文件

    Visual Studio Code 开发前端和node智能提示 visual studio code 是一个很好的编辑器,可以用来编写前端代码和nodejs. 我很喜欢使用VSC,现在流行框架对VS ...

  5. VS2013中实现angular代码智能提示

    第一步:在项目同添加angular js文件的引用: 这里使用NuGet包管理器来给项目添加angular js install-package angularjs 第二步:添加智能提示js文件 我们 ...

  6. ExtJS ComboBox 录入智能提示

    ExtJS ComboBox非常复杂,有很多的属性:其中有的属性是针对某一种特定的方案而设计的,不是所有情况下都有效.我想下拉选择能支持录入,并且录入时能智能提示,弄了半天可以了,但是只能是mode= ...

  7. Eclipse代码和xml文件的智能提示

    一.代码智能提示 Windows → Preferences → Java→ Editor → Content Assist 将 Auto activation delay(ms): 改为 0 将 A ...

  8. Laravel 安装代码智能提示扩展「laravel-ide-helper」

    ========================laravel-ide-helper======================== 使用 Laravel 框架IDE居然没有智能提示?这感觉实在太糟糕 ...

  9. 利用typescript使backbone强类型智能提示

    模型类一旦多了没有强类型和智能提示是相当痛苦的,所以. 仅仅用ts定义一个模型类: class Person extends Backbone.Model { defaults = { Name:&q ...

随机推荐

  1. iOS基础 - XML & JSON

    一.HTML & XML HTML 是用来描述网页的一种语言 HTML 指的是超文本标记语言 (Hyper Text Markup Language) HTML 不是一种编程语言,而是一种标记 ...

  2. 2014.first[未填]

    之后就按照自己的直觉,整理了第一套,难度为简单,差不多比2013noipday1水一点...先练练手而已 T1 vijos1196吃糖果游戏 博弈论 依题意,我们可知,如果去分数目为2,3,7,8必输 ...

  3. 使用axis2访问webservice(webserivice基于.net平台实现)

    webservice url=http://10.90.11.240:8081/ExceptionWebService.asmx?WSDL: 下载axis2组件,解压,进入bin目录,通过命令wsdl ...

  4. selenium webdriver (python)

    selenium webdriver (python) 第一版PDF Posted on 2013-08-30 22:59 虫师 阅读(221) 评论(0) 编辑 收藏 前言 如果你是一位有pytho ...

  5. java正则表达式验证汉字

    统计指定内容的汉字个数: String str = "北京欢迎你 hello welcome!"; int count=0; Pattern pattern = Pattern.c ...

  6. .NET开发规范教程

    .NET开发规范教程 这是1年多以前我在公司所做讲座的讲义,现在与园友们分享,欢迎拿去使用.一起讨论.文中有若干思考题,对园友们是小菜一碟.另有设计模式讲义一篇,随后发布. 1 概述 1.1 意义 “ ...

  7. 免费的Visual Studio的插件

    在做了深入(的)研究之后(通过在google网站搜索),,我编译了15个免费Visual Studio 2005插件表..其中一些插件将提高您(的)代码(的)质量,,另外一些能使您编译(的)更快,,但 ...

  8. Drupal与大型网站架构(译)- Large-Scale Web Site Infrastructure and Drupal

    Drupal与大型网站架构(译)- Large-Scale Web Site Infrastructure and Drupal Linuxjournal 网站经典文章翻译,原文地址: Large-S ...

  9. 自己做个 Tag标签

    这是效果图,下面是源码,时间有限,有时间再完善 http://files.cnblogs.com/wxwall/tag.zip

  10. Integer.parseInt(String s, int radix)方法介绍(修正版)

    先来说明一下Integer.parseInt(String s, int radix)的功能. Integer.parseInt(String s, int radix)就是将整数字符串s(radix ...