In ASP. net mvc, jQuery and angularjs are used together to transmit parameters and bind data. jqueryangularjs

Source: Internet
Author: User

In ASP. net mvc, jQuery and angularjs are used together to transmit parameters and bind data. jqueryangularjs

This is required. On a list page, you can click the details button to bring the record's primary key value to another page.
On the other page, obtain the record data and then display the record data on the webpage.

First use an animation to demonstrate:

 

Yesterday I share the http://www.cnblogs.com/insus/p/7017737.html for the ng-click parameters passed by angularjs for the ng-click event parameters passed

 
The above is just to pass in a value in ng-click, but in ASP. net mvc, you also need to pass this value to another view, ASP. net mvc Transfer Parameters (model) http://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. predictionmessage) ;}, function error (error) {alert (response. error. data );});};Source Code

 

In ASP. net mvc, the Controller receives the parameter Action to obtain the database data:

 

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 );}Source Code

 
After obtaining data from the database, a model is provided to the view. The following describes how to pass the model of ASP. net mvc to angularjs ng-model:

 

 

Transfer and bind to #3.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.