2017-03-22 21 views
0

我正在嘗試使用ng-click重定向頁面,這在ng-repeat中非常有用。ng-click in url重定向

  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單擊= 「gotoProfile(1)」,而不是一個1我需要{{students.id} }但無法獲得

  1. 控制器功能:

    $ scope.gotoProfile = function(sid){ console.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

這樣。

請幫忙。 謝謝 PRASHANT

+0

gotoProfile(學生。 ID)應該工作。 – Ved

+0

@感謝ved ..一個問題已經解決..但仍然堅持重定向url。 ( –

+0

)是什麼問題? – Ved

回答

1

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

和怎麼樣,而不是$location.url(rurl);如果你想打開一個新頁面

使用$window.location.href=(rurl);,用$window.location.href=(rurl,'_blank');