Click here to Skip to main content
15,888,062 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have this angularjs controller
C#
 angular.module('MyApp')  //extending angular module from first part
.controller('BudgetAndDetails', function ($scope, BDetail) { //explained    about controller in Part2
   $scope.budgetdetails = [];

   BDetail.GetBDetails().then(function (d) {
    $scope.budgetdetails = d.data;
});


   $scope.removeRow = function (item) {

    var index = $scope.budgetdetails.indexOf(item);
    if (index < 0) {
        $scope.budgetdetails.push(item)

    } else {
        $scope.budgetdetails.splice(index, 1)

    }


};

})


And I have written this json code in my C# controller

C#
[HttpPost]
   public JsonResult update(BudgetandDetails budget)
   {
       var obj = _db.budgets.FirstOrDefault(b => budget.budget.idBudget == b.idBudget);

       _db.budgets.Remove(obj);


       _db.SaveChanges();


       return Json(obj, JsonRequestBehavior.AllowGet);


   }


How do I add the code in my angularjs controller to call the json when I delete a row?


What I have tried:

I have tried using $http in angularjs to call the json but I an not sure how to use it after deleting the row in the angularjs table.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900