不能得到使用AngularJs textarea的价值 [英] can't getting textarea value using AngularJs
问题描述
<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>
我不能够使用AngularJS获得的textarea
值。所有输入
文本字段通过除文本域控制器获得
。我在做什么错了?
I'm not be able to get textarea
value using AngularJS. All the input
text fields are getting through the controller except the textarea
. What am I doing wrong ?
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
};
这是警报不确定...
It's alert undefined...
推荐答案
如果您有警报($ scope.tbAddress);
定位在那里,当然它会最终成为未定义
。一切都没有在这一点上被分配到 $ scope.tbaddress
。 (但也许你拥有了它前面定义,但它只是没有在code所示)。
If you have alert($scope.tbAddress);
positioned right there, of course it'll end up as undefined
. Nothing has been assigned to $scope.tbaddress
at this point. (but maybe you have it defined earlier, but it's just not being shown in the code).
我居然没有一个问题得到它的工作。我裹着绑定到提交按钮功能的警报。我能够获得的价值。 见我的例子。
I actually didn't have a problem getting it to work. I wrapped the alert in a function that is bound to the submit button. I'm able to get the value. See my example.
我也改变了你的 $范围
A位的自由。它的建议,每个 ngModel
有一个。
它的名字。因此,而不是 tbAddress
应该是 tb.address
。它有怎样的角度继承处理的事情。
I also took the liberty of changing your $scope
a bit. It's recommended that every ngModel
has a .
in it's name. So rather than tbAddress
it should be tb.address
. It has to do with how angular inheritance is handled.
请参考:
- AngularJS: dot in ng-model
- The Dot - egghead video
- Google results for 'angular use dots in models'
这篇关于不能得到使用AngularJs textarea的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!