首页 技术 正文
技术 2022年11月21日
0 收藏 424 点赞 3,720 浏览 2386 个字
function helloworld(name){
console.log("hello!!!!!"+name)
}
var name="zhangsan";
eval("helloworld(name)");

代码粘贴到谷歌的控制台能够看到

hello!!!!! zhangsan

能够使用这个功能—-返回用户选择的某行数据。

<smcs-search-input-table table-uniqueflag="b" table-resultjson="jsonresulta" table-showcols="showtablecolsa"  table-temprow="6"
table-querycol="0,1" table-outcol="0" table-callback="gettabledata(data)" resultcache="true" >
</smcs-search-input-table>

gettabledata(data)是用户自己定义函数。我会在directive封装标签的里面调用这个行数,把用户选择的某行数据以json对象返回给data.

</pre><pre name="code" class="javascript">//双击某行时,把选中的数据输出
$scope.selectRow = function (id){
if(id==1){
return;//标题行
}
var trtdid="#"+tableuniqueflag+""+id+(parseInt(tableoutcol)+1);//取id
var trtdval=$(trtdid).text();//取值
var trtdidarray=new Array();//<td>id数组
//trtdidarray = ["#b41", "#b42", "#b43"]
var trtdvalarray=new Array();//<td>中内容数组
//trtdvalarray=["a王武", "男", "北京"]
for(var i=0;i<cells;i++){
trtdidarray[i]="#"+tableuniqueflag+""+id+(parseInt(i)+1);
//表格一行的数据
trtdvalarray[i]=$(trtdidarray[i]).text();
}
console.log(colattrs);
//colattrs=["testname", "sex", "addr"]//json格式 { "testname": "a张三", "sex": "男","addr":"天津","tel":"138"}
data="{"
for(var j=0;j<cells;j++){
data=data+'\"'+colattrs[j]+'\"'+":"+'\"'+trtdvalarray[j]+'\"';
if(j<(cells-1)){
data=data+","
}
}
data=data+"}"
//调用用户再app.controller中定义的回调函数。
$scope.tablecallbackfun(JSON.parse(data));
//把选中的项填写到输入框
document.getElementById("inputable"+tableuniqueflag).value = trtdval;
$(mydivlocation).css('display','none');
}
//选中某行并将值的字符串返回父页面
$scope.tablecallbackfun = function(data){
eval("$scope."+tablecallback);
}

app.controller

(function(){
var app = angular.module('SMCS.App');app.controller('MedicareInstitutionInfoMaintainCtrl', ['$scope','$http', 'BaseURL','$modal','Modal',function($scope,$http,BaseURL,$modal,Modal){//后台返回数据
$scope.jsonresulta = [{ "testname": "a张三", "sex": "男","addr":"天津","tel":"138"},
{ "testname": "a张狗", "sex": "男","addr":"上海","tel":"138"},
{ "testname": "a王武", "sex": "男","addr":"北京","tel":"138"},
{ "testname": "a张武", "sex": "男","addr":"北京","tel":"138"},
{ "testname": "a花木兰", "sex": "女","addr":"北京","tel":"138"}
];$scope.showtablecolsa = [
{ label: '姓名', map: 'testname'},
{ label: '性别', map: 'sex'},
{ label: '住址', map: 'addr'}
];$scope.gettabledata = function(data){
//data json对象,能够取里面的属性,相比原来返回一个值更灵活
console.log("sex==="+data.sex);
}}]);})()

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,078
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,553
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,402
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,177
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,814
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898