This article mainly introduces the application of jquery and Angularjs to data binding in ASP.
The requirement is this, in a list page, the user clicks on the Detailed ammonium button, with the recorded primary key value to another page.
On another external page, get the record data, and then display this record data on the Web page.
First, use the dynamic diagram to demonstrate:
The above is just passing in a value in Ng-click, but in ASP. NET MVC you also need to pass this value to another view. asp. NET MVC pass parameters (model)
Www.cnblogs.com/insus/p/6148167.html
$scope. Detail = function (code) { var objects = {}; Objects. Key = code; Objects. Value = ""; Objects. Controller = "Code"; Objects. Action = "Clausedetail"; $http ({ method: ' POST ', URL: '/pass/redirect ', dataType: ' json ', headers: { ' content-type ': ' Application/json; Charset=utf-8 ' }, data:JSON.stringify (objects), }). Then ( function Success (response) { if (response.data.Success) { window.location.href = response.data.RedirectUrl; } else { alert (response.data.ExceptionMessage)} }, function error (Error) { alert ( Response.error.data);};
The action receive parameter in the controller of the ASP. NET MVC gets the data for the database:
Public ActionResult Clausedetail () { if (tempdata["Pass"] = = null) return redirecttoaction ("Clause", " Code "); var pass = tempdata["Pass") as pass; tempdata["Pass" = Pass; Clause C = new Models.clause (); C.code = Pass. Key.tostring (); Clauseentity CE = new clauseentity (); var model = CE. Clausebykey (c). FirstOrDefault (); return View (model); }
After fetching the data from the database, give the view a model. Here is the focus of this article, how to pass the model of ASP. Angularjs Ng-model: