angular js需要帮助设置表格中的动态链接

时间:2021-11-11 19:22:31

I am trying to set a link so it is dynamic, here is the function

我试图设置一个链接,因此它是动态的,这是函数

$scope.prodFunc = function(){
            var tempData = "{http://###001dcpas01.##########.com, EVT-MQ-VNM:9102}";
            var config = {

                headers : {

                    'Content-Type': 'application/json'

                }
            };

I need the ###-MQ-VNM:9102 to be dynamic based on the table row. Here is the table data and the event.dcpName is what needs to be dynamic when check is clicked.

我需要### - MQ-VNM:9102基于表行是动态的。这是表数据,event.dcpName是单击检查时需要动态的。

<table class="table table-bordered rest-services-table table-centered">
        <tr>
          <th class="text-center">JVM Host</th>
          <th>DCP Process</th>
          <th>Health Check</th>
          <th class="text-center">Check Status</th>
        </tr>

        <tr ng-repeat="event in events">
          <td>{{event.jvmName}}</td>
          <td>{{event.dcpName}}</td>
          <td>{{event.status}}</td>
          <td ><a href="" ng-click="prodFunc()">Check</a></td>
        </tr>
      </table>


<p>this is my first time posting so please be gentle :) Thank you,

Jim

1 个解决方案

#1


1  

You can pass the data you need to your prodFunc function like this:

您可以将所需的数据传递给prodFunc函数,如下所示:

<tr ng-repeat="event in events">
     <td>{{event.jvmName}}</td>
     <td>{{event.dcpName}}</td>
     <td>{{event.status}}</td>
     <td ><a href="" ng-click="prodFunc(event.dcpName)">Check</a></td>
 </tr>

Then you can use it like so:

然后你可以像这样使用它:

$scope.prodFunc = function(dcpName){

    // something like this string concatenation ??
    var dynamicLink = "http://###001dcpas01." + dcpName + ".com:9102";

    // this temp data doesn't look right to me vvv ?

    var tempData = "{http://###001dcpas01.##########.com, EVT-MQ-VNM:9102}";
    var config = {

         headers : {

             'Content-Type': 'application/json'

         }
     }
}     

Alternatively you could do it like this with ngHref directive and skip the click funtion:

或者你可以使用ngHref指令这样做,并跳过点击功能:

<tr ng-repeat="event in events">
         <td>{{event.jvmName}}</td>
         <td>{{event.dcpName}}</td>
         <td>{{event.status}}</td>
         <td ><a ng-href="http://someurl{{event.dcpName}}.com:port" >Check</a></td>
</tr>

#1


1  

You can pass the data you need to your prodFunc function like this:

您可以将所需的数据传递给prodFunc函数,如下所示:

<tr ng-repeat="event in events">
     <td>{{event.jvmName}}</td>
     <td>{{event.dcpName}}</td>
     <td>{{event.status}}</td>
     <td ><a href="" ng-click="prodFunc(event.dcpName)">Check</a></td>
 </tr>

Then you can use it like so:

然后你可以像这样使用它:

$scope.prodFunc = function(dcpName){

    // something like this string concatenation ??
    var dynamicLink = "http://###001dcpas01." + dcpName + ".com:9102";

    // this temp data doesn't look right to me vvv ?

    var tempData = "{http://###001dcpas01.##########.com, EVT-MQ-VNM:9102}";
    var config = {

         headers : {

             'Content-Type': 'application/json'

         }
     }
}     

Alternatively you could do it like this with ngHref directive and skip the click funtion:

或者你可以使用ngHref指令这样做,并跳过点击功能:

<tr ng-repeat="event in events">
         <td>{{event.jvmName}}</td>
         <td>{{event.dcpName}}</td>
         <td>{{event.status}}</td>
         <td ><a ng-href="http://someurl{{event.dcpName}}.com:port" >Check</a></td>
</tr>