AngularJs如何传递Json字符串到$scope.msg=msg.data

AngularJs how to pass Json String into $scope.msg=msg.data

本文关键字:msg scope data 何传递 Json 字符串 AngularJs      更新时间:2023-09-26
public JsonResult Authe(string Email, string Password, bool ? Active) {
    var x = (from n in db.Authntications where n.Email == Email && n.Password == Password select n).FirstOrDefault();
    if (x != null) {
        var xx = (from n in db.Authntications where n.Email == Email && n.Password == Password && n.Active == Active select n).FirstOrDefault();
        if (xx == null) {
            msg = "Your A/c not activated....";
        }
    } else
        msg = "Your Account Details Not Valid  please check Details You mentiond...";
    return new JsonResult {
        JsonRequestBehavior = JsonRequestBehavior.AllowGet
    };
}

AngularJs

var ZmrSer = MyAuthneticService.Authen(Sucess);
$scope.msg = msg.data; 
$('#modalSuccess').modal('show');

您应该从允许get行为的操作方法返回Json

return Json(msg, JsonRequestBehavior.AllowGet);