Paste the code into Google's console to see
Hello!!!!! Zhangsan
You can use this feature----return a row of data that is selected by the user.
<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) is a user-defined function. I will call this number of lines in the directive package tag and return the data selected by the user to the JSON object.
</pre><pre name= "Code" class= "JavaScript" >//double-click a row to output the selected data $scope. SelectRow = function (ID) {if (id==1) { return;//Header Line}var trtdid= "#" +tableuniqueflag+ "" +id+ (parseint (Tableoutcol) +1);//Take Idvar trtdval=$ (trtdid). text ();// Value var trtdidarray=new array ();//<td>id array//trtdidarray = ["#b41", "#b42", "#b43"]var trtdvalarray=new Array ();// <td> content Array//trtdvalarray=["a Wang Wu", "Male", "Beijing"]for (var i=0;i<cells;i++) {trtdidarray[i]= "#" +tableuniqueflag+ "" +id+ (parseint (i) +1);//Data trtdvalarray[i]=$ (Trtdidarray[i]) of the table row. text ();} Console.log (colattrs);//colattrs=["testname", "Sex", "addr"]//json format {"testname": "A Zhang San", "Sex": "Male", "addr": "Tianjin", "tel ":" 138 "}data=" {"for (Var j=0;j<cells;j++) {data=data+ ' \" ' +colattrs[j]+ ' \ "' +": "+ ' \" ' +trtdvalarray[j]+ ' \ "'); if (j < (cells-1)) {data=data+ ","}}data=data+ "}"//Call the user again App.controller the callback function defined. $scope. Tablecallbackfun (data);//fill in the selected entries into the input box document.getElementById ("Inputable" +tableuniqueflag). Value = trtdval;$ (mydivlocation). CSS (' Display ', ' none ');} Select a row andThe value of the string returns the parent page $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) {//background return Data $scope.jsonresulta = [{"TestName": "A Zhang San", "Sex": "Male", "addr": "Tianjin "," tel ":" 138 "},{" testname ":" A Dog "," sex ":" Male "," addr ":" Shanghai "," tel ":" 138 "},{" testname ":" A Wang Wu "," Sex ":" Male "," addr ":" Beijing "," Tel ":" 138 "},{" testname ":" A Chang Buri "," Sex ":" Male "," addr ":" Beijing "," tel ":" 138 "},{" testname ":" A Mulan "," Sex ":" female "," addr ":" Beijing "," tel ":" 138 "}]; $scope. Showtablecolsa = [{label: ' name ', map: ' TestName '},{label: ' Gender ', map: ' Sex '},{label: ' Address ', map: ' Addr '}] , $scope. Gettabledata = function (data) {//data JSON object, can take the property inside, compared to the original return a value of flexible console.log ("sex===" +data.sex);}]);}) ()
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Angularjs Add a callback function to a custom tag eval ()