In my ASP.Net/MVC application, I am using AngularJS to display a list of records from the database. When I update a record, it doesn't get updated in the view (html) until I refresh the page?
The view:
<tr ng-repeat="bu in bus">
<td>{{bu.BU_Name}}</a></td>
<td>{{bu.BU_Info}}</a></td>
<th><a href="javascript:void(0)" ng-click="editItem(bu)">Del</a></th>
</tr>
The JS:
$scope.editItem= function (bu) {
$http.post('/CO/DelBU', {dbunt: bu})
.then(function (response) {
$scope.bus = response.data;
})
.catch(function (e) {
console.log("error", e);
throw e;
})
.finally(function () {
console.log("This finally block");
});
};
The MVC controller:
[HttpPost]
public JsonResult DelBU(BUs dbunt)
{
var db = new scaleDBEntities();
var burecord = db.Buses.Find(dbunt.BU_ID);
db.Database.ExecuteSqlCommand("UPDATE dbo.BUs SET BU_Name='just a test'");
var burecords = db.Buses.ToList();
return Json(burecords, JsonRequestBehavior.AllowGet);
}
So, when I click on edit, the name doesn't change on the screen unless I refresh the page! How can I fix this?
Thank you