0
我使用的ui-sref通過一個id給定的url頁面。但我想要從控制器JS文件而不是HTML傳遞相同的id和url。 HTML:如何使用JavaScript中的數據傳遞URL而不是HTML中的ui-sref?
<button ui-sref="Followup({patient:patientid.id})">
OK </button>
是否有可能通過從控制器上面的標識和網址得到相同的結果?
我使用的ui-sref通過一個id給定的url頁面。但我想要從控制器JS文件而不是HTML傳遞相同的id和url。 HTML:如何使用JavaScript中的數據傳遞URL而不是HTML中的ui-sref?
<button ui-sref="Followup({patient:patientid.id})">
OK </button>
是否有可能通過從控制器上面的標識和網址得到相同的結果?
可以使用ng-click
像以下:
<button ng-click="followup(patient)">
OK </button>
和控制器:
$scope.followup = function (patient){
$state.go('Followup', {patient:patient.id});
}
做這個
<button ng-click="go()"> OK </button>
在控制器
$scope.go = function (patient){
$state.go('Followup', {patientid:patient.id});
}
我不知道patientid.id
正確與否在你的問題,所以我認爲,我們有病人的對象,我們希望瀏覽到參數的下一頁作爲患者ID。
如果它工作正常,請選擇最佳答案,因爲沒有其他的答案了..謝謝投票。 –