这是我的plnkr:http://plnkr.co/edit/n8cRXwIpHJw3jUpL8PX5?p = preview 你必须点击一个li元素,表格才会出现.输入随机字符串并点击"添加通知".而不是textarea文本,你将得到未定义.
标记:
<ul>
<li ng-repeat="ticket in tickets" ng-click="select(ticket)">
{{ ticket.text }}
</li>
</ul>
<div ui-if="selectedTicket != null">
<form ng-submit="createNotice(selectedTicket)">
<textarea ng-model="noticeText"></textarea>
<button type="submit">add notice</button>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
JS部分:
$scope.createNotice = function(ticket){
alert($scope.noticeText);
}
Run Code Online (Sandbox Code Playgroud)
返回'undefined'.我注意到当使用ui-if of angular-ui时这不起作用.任何想法为什么这不起作用?怎么解决?
<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)
这是警报未定义......