Tar*_*riq 0 javascript angularjs angularjs-directive angularjs-scope
<tr class="labels">
<td nowrap="nowrap">Address</td>
<td nowrap="nowrap"><label for="tbAddress"></label>
<textarea name="tbAddress" id="tbAddress" cols="39" rows="5" ng-model="$parent.tbAddress"></textarea>
</td>
</tr>
<tr>
<td> </td>
<td align="right">
<input type="submit" name="button" id="button" value="Submit Record" class="btns" />
<input type="reset" name="button2" id="button2" value="Cancel" class="btns" />
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
我无法textarea使用AngularJS 获得价值.所有input文本字段都通过控制器,除了textarea.我究竟做错了什么 ?
alert($scope.tbAddress);
var thisData = {
'name': $scope.tbFN,
'company': $scope.tbCompany,
'designation': $scope.tbDesignation,
'email': $scope.tbEmail,
'phone': $scope.tbPhone,
'mobile': $scope.tbMobile,
'address': $scope.tbAddress
};
Run Code Online (Sandbox Code Playgroud)
这是警报未定义......
如果你已经alert($scope.tbAddress);定位在那里,当然它最终会成为undefined.此时尚未指定任何内容$scope.tbaddress.(但也许你之前已定义它,但它只是没有在代码中显示).
我实际上没有问题让它工作.我将警报包含在绑定到提交按钮的函数中.我能够获得价值.看看我的例子.
我也冒昧地改变了你$scope的一点.建议每个人ngModel都有一个.名字.所以而不是tbAddress应该tb.address.它与角度继承的处理方式有关.
参考:
| 归档时间: |
|
| 查看次数: |
4374 次 |
| 最近记录: |