ANGULARJS Custom Label Add callback function eval ()

Source: Internet
Author: User

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 ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.