问题描述
HTML:
<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);}
(这边参数Name一直NULL,就是说,JS那边不能把值传过来)
问题解答
回答1:直接在浏览器输入 ../Movies/Search/xxxx 看看服务端有没有值,如果这样服务端还没有值,说明不是 Angular $http的问题,是你的ASP.NET MVC的路由设置有问题。