【问题标题】:ng-click in ng-repeat with url redirectng-click 在 ng-repeat 中使用 url 重定向
【发布时间】:2017-03-22 06:47:54
【问题描述】:

我正在尝试使用 ng-repeat 中可用的 ng-click 重定向页面。

  1. ng-重复代码:

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

这里在 ng-click="gotoProfile(1)" 而不是那个 1 我需要 {{students.id}} 但无法获得

  1. 控制器功能:

    $scope.gotoProfile = 函数 (sid) { 控制台.log($scope.purl); var rurl = $scope.purl+sid; $location.url(rurl); };

当我运行这个时,我得到了 url

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

像这样。

请帮忙。 谢谢你 普拉尚特

【问题讨论】:

标签: angularjs


【解决方案1】:

使用&lt;tr ng-repeat="students in studlist" ng-click="gotoProfile(student.id)"&gt;发送student.id

以及如何使用$window.location.href=(rurl); 而不是$location.url(rurl);

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

【讨论】:

    猜你喜欢
    • 2015-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多