我有一張表格,裏面充滿了來自數據庫的信息。它也有一個提交按鈕。如果該行上的人尊重我登記控制器的某個條件,則該按鈕不應出現。我怎樣才能做到這一點?根據表格行信息隱藏加載的角度按鈕
我試着設置一個返回true或false的函數,但該函數會連續運行並崩潰我的程序。我也嘗試設置該功能在一段時間間隔運行,並沒有改變按鈕。問題是我認爲,在開始時,當我加載頁面時,客戶端無法從表中獲取任何信息,它總是未定義。
代碼的html:
<form>
<table class="table table-hover">
<thead>
<tr>
<th>Id</th>
<th>Status</th>
<th>Location</th>
<th>Start</th>
</tr>
</thead>
<tbody>
<tr data-ng-repeat="interview in $ctrl.pendingInterviews">
<td>{{ interview.id }}</td>
<td>{{ interview.status }}</td>
<td>{{ interview.location }}</td>
<td>{{ interview.start | date:'medium' }}</td>
<td><input type="submit" name="Submit" id="submit" ng-hide="varDiv" ng-click="varDiv = true; $ctrl.addParticipant(interview.id)"></td>
</tr>
</tbody>
</table></form>
現在它後,我點擊它,這也不行,因爲當我重新加載,它再次出現只是自敗。
this.checkIfAdded = function checkParticipant(interviewId) {
var participant={
username:"mama",
interviewId:interviewId
};
return Interview.checkIfAdded(JSON.stringify(participant))
.then(
function (errResponse) {
console.error('Error while fetching pending interviews');
}
);
}
這將返回true或false我認爲它基於從Interview.checkIfAdded獲得的內容。
但我從來沒有看到範圍。我只是從服務器加載它,並將其解析爲html文件,如上所示。我無法在JSON中手動添加字段,因爲我真的需要查看JSON並使用它。 – Mocktheduck
如何確定是否顯示按鈕? –
我有一個按Id檢索採訪的函數,它獲取與它匹配的所有用戶,並檢查當前用戶是否在該列表中。這是後端的一個函數,返回true或false。 – Mocktheduck