ng-repeat没有获得值

时间:2016-03-31 04:01:18

标签: angularjs json

我有两个单选按钮和textarea,我必须从mysql数据库绑定ng-repeat数据。那我怎么能这样做呢。

    <label>Gender:</label>
        <input type="radio" name="gender"ng-value = "x.gender" ng-model="stdCtrl.gender" value="male" required>Male</input>
        <input type="radio" name="gender"ng-value = "x.gender" ng-model="stdCtrl.gender" value="female" required>Female</input>



    <label>Home-Address</label>
        <textarea name = "address"
            ng-required = "true"
            ng-value = "x.address"
            ng-model = "stdCtrl.address"
            class = "form-control"
            placeholder = "PresentAddress"
            row = "10" cols = "50" ></textarea>

现在问题是我无法从我的url数据中获取textarea值,其中我将详细信息带入控制器。这是我的网址解码数据。

$scope.StudentCtrl = function(){
alert("bye");
    var vars = {};
    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,    
    function(m,key,value) {
      vars[key] = value;
    });
    return vars;
   }
 var fType = JSON.parse(decodeURIComponent($scope.StudentCtrl()['data']));
console.log(fType);
$scope.fType = fType;

1 个答案:

答案 0 :(得分:1)

我找到了textarea元素的答案来绑定ng-repeat数据。

<textarea name = "address"
                ng-required = "true"
                ng-bind = "x.address"
                ng-model = "stdCtrl.address"
                class = "form-control"
                placeholder = "PresentAddress"
                row = "10" cols = "50" ></textarea>

因此,通过添加ng-bind指令,您将能够绑定ng-repeat中的数据,并返回您在第一部分键入数据的方式。