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.ExceptionMessage);           }         },        function error(error) {          alert(response.error.data);        });    };

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

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:

The above is a small series of ASP. in net mvc, The jQuery and angularjs hybrid applications transmit parameters and bind data. I hope this will be helpful to you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.