मेरी कोणीय ऐप्लिकेशन में करने के बाद दृश्य अपडेट नहीं हो मैं एक नियंत्रक के रूप में निम्नानुसार है इस संसाधन:
function TemplateListControl($scope, TemplateService){
$scope.templates = TemplateService.get(); // Get objects from resource
// Delete Method
$scope.deleteTemplate = function(id){
$scope.templates.$delete({id: id});
}
}
दृश्य मैं एक मेज thats templates
मॉडल करने के लिए बाध्य है के भीतर। इस प्रकार है:
<table ng-model="templates">
<thead>
<tr>
<th style="width:40%">Title</th>
<th style="width:40%">controls</th>
</tr>
<thead>
<tbody>
<tr ng-repeat="template in templates">
<td>
<!-- Link to template details page -->
<a href="#/template/[[template.id]]">
[[template.title]]
</a>
</td>
<td>
<!-- Link to template details page -->
<a class="btn btn-primary btn-small"
href="#/template/[[template.id]]">Edit
</a>
<!-- Link to delete this template -->
<a class="btn btn-primary btn-small"
ng-click="deleteTemplate(template.id)">Delete
</a>
</td>
</tr>
</tbody>
</table>
अब जब मैं ऊपर टेम्पलेट में नष्ट लिंक पर क्लिक करें, यह deleteTemplate
प्रणाली को बुलाती है और एक सफल DELETE
कॉल REST API करने के लिए किया जाता है। लेकिन दृश्य को तब तक अपडेट नहीं किया जाता है जब तक इसे रीफ्रेश नहीं किया जाता है और $scope.templates = TemplateService.get();
फिर से शुरू किया जाता है। मैं क्या गलत कर रहा हूं?
और हम कैसे जानते हैं कि आरईएसटी एपीआई के लिए असीमित कॉल सफल हुआ है या नहीं? मुझे यकीन है कि कोणीय के संसाधन को तदनुसार दृश्य को अद्यतन करना चाहिए। यदि हमें मैन्युअल रूप से क्लाइंट साइड पर डेटा अपडेट करना है, तो हमें मैन्युअल रूप से त्रुटि प्रबंधन करने की भी आवश्यकता होगी, जो मुझे विपरीत दिशा में जाने जैसा लगता है। – Amyth
क्या आप कृपया बेवकूफ साझा कर सकते हैं –