ng-click with ng-repeat with url redirect

时间:2017-03-22 06:47:54

标签: angularjs

我正在尝试使用ng-click重定向页面,这在ng-repeat中有用。

  1. ng-repeat code:

                <tr ng-repeat="students in studlist" ng-click="gotoProfile(1)">
                    <td width="12%" class="student-list-pic-column"><img src="<?=base_url()."data/student-img/{{ students.photo }}";?>"></td>
                    <td width="50%" class="custom-table-border-body text-left">{{ students.studname }}</td>
                    <td width="38%">{{ students.bid }}</td>
                </tr>
                <tr ng-show="!studlist.length">
                    <td colspan="3" class="custom-table-border-body text-center">
                        Search student name ...
                    </td>
                </tr> 
    
  2. 这里是ng-click =&#34; gotoProfile(1)&#34;而不是那个我需要{{students.id}}但是无法获得

    1. 控制器功能:

      $ scope.gotoProfile = function(sid){     的console.log($ scope.purl);     var rurl = $ scope.purl + sid;     $ location.url(RURL); };

    2. 当我运行这个时,我得到了网址

      http://localhost/product/tcm_dev/utility/dashboard#/http://localhost/product/tcm_dev/utility/student/profile/1

      像这样。

      请帮忙。 谢谢 PRASHANT

1 个答案:

答案 0 :(得分:1)

使用<tr ng-repeat="students in studlist" ng-click="gotoProfile(student.id)">发送student.id

以及如何使用$window.location.href=(rurl);代替$location.url(rurl);

如果您想要打开新页面,请使用$window.location.href=(rurl,'_blank');