angular.js - ANGULARJS HTTP.GET传值,后台收不到参数值
HTML:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <code><button type= "submit" ng-click= "get3(model.Name)" >查询</button>
js:
$scope .get3 = function (name) {
$http .get( "/Movies/Search/" + name).success( function (data) {
$scope .model = data;
})
}(这边name可以收到前台传过来的值)
MVC CONTROLLER:
public ActionResult Search(string Name)
{
var movie9 = db.Movies.Where(p => p.Name == Name);
Movie movied = (Movie)movie9;
return Json( new
{
Name = movied.Name,
Genra = movied.Genra
}, JsonRequestBehavior.AllowGet);
}
</code>
|
(这边参数Name一直NULL,就是说,JS那边不能把值传过来)