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

时间:2016-10-26 18:02:31

标签: angularjs

我正在尝试设置链接,因此它是动态的,这是函数

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

                headers : {

                    'Content-Type': 'application/json'

                }
            };

我需要### - 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,

吉姆

1 个答案:

答案 0 :(得分:1)

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

$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'

         }
     }
}     

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

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

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

^none(?!\S)|[\w.%+-]+@[\w.-]+\.[a-zA-Z]{2,6}$