0
在MVC JsonResult殘疾人專用我有一個模型類是這樣的: -值是不是從角功能
public class InternShip
{
[Key]
public int ID { get; set; }
public string Name { get; set; }
public string Descr { get; set; }
public int Amount { get; set; }
public int Duration { get; set; }
public DateTime CreatedDate { get; set; }
public DateTime ExpiryDate { get; set; }
}
現在我已經在我創建NG-click事件的看法: -
<a ng-click="IntrnDetail(r.ID)" style="cursor:pointer"><h5>{{r.Name}}</h5></a>
在點擊我的價值傳遞給它由功能handeled我的角度文件InternShip.js: -
$scope.IntrnDetail = function (InternID) {
window.location.href = '/Home/InternDetail/' + InternID;
}
現在我的控制器(HomeController的)擁有的ActionResult(InternDetail)爲: -
[HttpGet]
public JsonResult InternDetail(string InterID)
{
List<InternShip> Intern = new List<InternShip>();
int IntID = Convert.ToInt32(InterID);
using (EBContext db = new EBContext())
{
Intern = db.Interns.Where(x => x.ID == IntID).ToList();
}
return new JsonResult{ Data= Intern, JsonRequestBehavior=JsonRequestBehavior.AllowGet};
}
但問題是,雖然值內InternShip.js的InternID但在JsonResult未來(InternDetail)InterID越來越空。我不知道爲什麼會發生這種情況。
請幫助!
這做到了。謝謝你的解釋。 – Deepak