2013-07-12 2 views
0

나는 AngularJS에서 편집 양식을 가지고 있으며 각도 데이터 바인딩을 통해 텍스트 상자에 데이터를 표시하려고합니다.AngularJS, Databind Multiple Form Fields

여기까지 제가 지금까지 해 온 양식입니다.

{"datas":[{"UserID":"168","UserName":"fdaa","Cnic":"23424","Email":"[email protected]","Password":"asdad","Age":"12","Gender":"Male","Picture":null,"InGameName":"fds","ContactID":null,"GroupID":null,"ClanID":null}]} 

을하지만 어떻게 각도 데이터 바인딩을 통해 텍스트 상자에이 값을 표시하려면 다음

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/html"> 
<head> 
    <link href="<?php echo base_url(); ?>/styles/formcss.css" rel="stylesheet" type="text/css"/> 
    <script src="<?php echo base_url(); ?>/scripts/angular.min.js"></script> 
</head> 
    <body ng-app> 
    <div ng-controller="controller"> 
    <form> 
    <label for="name">UserID:</label> <input type="text" name="UserID" ng-model="user.UserID" value=""><br> 
    <label for="UserName">Name:</label> <input type="text" name="UserName" ng-model="user.UserName" value=""><br> 
    <label for="rollno">In Game Name:</label> <input type="text" name="GameName" ng-model="user.InGameName" value="" ><br> 
    <label for="father">CNIC Number:</label> <input type="number" name="Cnic" ng-model="user.Cnic" value="" ><br> 
    <label for="age">Age:</label> <input name="Age" ng-model="user.Age" type="number" value="" ><br> 
    <label for="email1">Email:</label> <input name="Email" ng-model="user.Email" type="email" value="" ><br> 
    <label for="email2">Res enter Email:</label> <input id="email2" type="email" name="email2" value="" ><br> 
    <label for="pass1">Password:</label> <input id="pass1" type="password" name="Pass" ng-model="user.Password" value=""><br> 
    <label for="pass2">Re enter Password:</label> <input id="pass2" type="password" name="pass2" value="" ><br> 
    <label style="margin-bottom:-10px; " for="male">Male</label><input class="gen" ng-model="user.Gender" id="male" type="radio" name="g" value="Male"><br> 
    <label style="margin-bottom:15px;" for="female">Female</label><input class="gen" ng-model="user.Gender" id="female" type="radio" name="g" value="Female"><br> 
    <label class="dis" for="about" >About:</label> <textarea rows="5" cols="40" id="about" type="text" value=""></textarea><br> 
    <button style="margin-left: 225px;" ng-click="save()" >Save</button> 
    </form> 
    </div> 
    <script> 
     function controller ($scope,$http) 
     { 
      var angularform="<?php echo base_url(); ?>index.php/datacon/angform" 
      $scope.save=function() 
      { 
      $http.post(angularform, $scope.user); 
      } 
     } 
    </script> 
    </body> 
</html> 

는 JSON 배열은 내가 컨트롤러 JSON에서 얻기하고 있습니까?

만약 내가 뭔가를 잘못하고 있다면 실수로 나를 리디렉션하여 실수를 해결할 수있게하십시오.

+0

ng-model에 대해 자세히 알아보기 –

답변

0

나는 당신이 옳은지 여부를 확신하지 못합니다. 하지만 $scopeng-model을 사용하고 있다면 완벽하게 작업하고 있다고 생각합니다. 당신은 절대적으로 정확한 것을 사용하고 있습니다.

$http.post()을 사용하면 데이터를 저장할 수 있습니다. 동시에 텍스트 상자에 데이터가 나타납니다.

정확히하고 싶습니다. 여러분이 더 설명 할 수 있도록 좀 더 설명해주십시오.