Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
391 views
in Technique[技术] by (71.8m points)

asp.net - 在AngularJS中将变量分配为JSON格式(assign variables to JSON format in AngularJS)

I want to separate variables to data

(我想将变量与数据分开)

I am working with AngularJS and aso.net which filled out a survey form and launches the result (data) ($ scope.data) which I want to separate two variables that become records to take to the ASP.net controller.

(我正在与AngularJS和aso.net一起使用,后者填写了调查表并启动了结果(数据)($ scope.data),我想将两个变量分开,这些变量成为记录并存入ASP.net控制器。)

JSFiddle or CopePen

(JSFiddle或CopePen)

CODE

()

$scope.data = [{ 
  "Age":"3",
  "Gender":"0",
  "IdSurvey":"5de12546fcfabc3c50660d35",
  "5de12577fcfabc3c50660d36":"5de125c1fcfabc3c50660d3b",
  "5de12585fcfabc3c50660d37":"5de125cbfcfabc3c50660d3c",
  "5de125a8fcfabc3c50660d38":"5de125f8fcfabc3c50660d40" // sample
}];


$scope.surveyAnswer = {};
$scope.Survey_Save = function () {

  $scope.surveyAnswer.Age = $scope.data.Age;
  $scope.surveyAnswer.Gender = $scope.data.Gender;
  $scope.surveyAnswer.IdSurvey = $scope.data.IdSurvey;
  $scope.surveyAnswer.IdSurveyQuestion = $scope.data.IdSurveyQuestion;
  $scope.surveyAnswer.IdSurveyQuestionAnswer = $scope.data.IdSurveyQuestionAnswer;

  //  $scope.surveyAnswer.IdSurveyQuestion = "5de125a8fcfabc3c50660d38";
  //  $scope.surveyAnswer.IdSurveyQuestionAnswer = "5de125f8fcfabc3c50660d40";
}

this is mi model in ASP.Net

(这是ASP.Net中的mi模型)

using MongoDB.Bson.Serialization.Attributes;

namespace Company.Models
{
    public class SurveyAnswerModel
    {

        [BsonId]
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]

        public string Id { get; set; }
        public string IdSurvey { get; set; }
        public int Age { get; set; }
        public int Gender { get; set; }

        public string IdSurveyQuestion { get; set; }
        public string IdSurveyQuestionAnswer { get; set; }
    }
}
  ask by R O D O translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...