文本框不显示从Action Result返回的json数据

时间:2017-04-19 07:29:18

标签: angularjs asp.net-mvc

这是我的行动结果:

public ActionResult getchqStartNum()
{
    tblChqIssue tblci = new tblChqIssue();
    DataTable dt = objemp.ChqIssueBs.showChqStartNo();
    if (dt.Rows.Count > 0)
    {
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            decimal a = Convert.ToDecimal(dt.Rows[i][5].ToString());
            decimal b = a + 1;
            tblci.chqStartNo = b;
        }
    }
    else
    {
        tblci.chqStartNo = 1;
    }
    return Json(tblci.chqStartNo, JsonRequestBehavior.AllowGet);
}

以下是我的角度代码:

$scope.GetChqStartNo = function () {
    crudServiceUser.getChqStartNo().then(function (result) {
        $scope.Chqs = result;     })
 }

  crudUserObj.getChqStartNo = function () {
  var Emp;
  Emp = $http({
      method: 'Post',
      url: '/Employee/ChequeIssue/getchqStartNum'
  }
  ).then(function (response) {
      return response.data;
  });
  return Emp;
 }

  return crudUserObj;
});

以下是我的观点:

<div class="col-md-10">
    @Html.TextBoxFor(model => model.chqStartNo, new { type = "text", ng_model = "Chqs.chqStartNo" }){{Chqs.chqStartNo}}
    @Html.ValidationMessageFor(model => model.chqStartNo, "", new { @class = "text-danger" })                
</div>

文本框chqStartNo未显示数据,即从操作结果返回的数据:

else
{
    tblci.chqStartNo = 1;
}
return Json(tblci.chqStartNo, JsonRequestBehavior.AllowGet);

文本框应该显示1但它没有显示任何内容。代码中是否有任何错误?

1 个答案:

答案 0 :(得分:0)

public ActionResult getchqStartNum()
{
    tblChqIssue tblci = new tblChqIssue();
    DataTable dt = objemp.ChqIssueBs.showChqStartNo();
    if (dt.Rows.Count > 0)
    {
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            decimal a = Convert.ToDecimal(dt.Rows[i][5].ToString());
            decimal b = a + 1;
            tblci.chqStartNo = b;
        }
    }
    else
    {
        tblci.chqStartNo = 1;
    }
    return Json(tblci.chqStartNo, JsonRequestBehavior.AllowGet);
}