我正在尝试在输入框上设置NG模型(如果重要的话,在表单内),但它似乎不会在$ scope上设置。每次我在控制器的if语句上设置一个断点' lpScan'总是空白的。我试图在屏幕上显示{{lpScan}},但它似乎也没有在那里设置。有人对这可能是什么有任何想法吗?
以下是一小段控制器代码:
$scope.submitLP = function () {
$scope.lpScan = "";
if (!$scope.checkInForm.$valid) {
$scope.formValidate = 1;
return;
}
if ($scope.scanRequired && $scope.lpScan !== $scope.lp.LPNumber) {
FoundationApi.publish('load-notification',
{
title: 'Invalid LP',
content: 'Must scan current LP to receive it.',
autoclose: '4000'
});
}
这是html
<div class="full-block">
<form name="checkInForm">
<div class="center data-item">
<div class="button" ng-click="reprintLP()">Reprint LP</div>
</div>
<div class="data-item" ng-if="scanRequired && !lp.CheckedIn"
</div>
<div class="data-label-narrow">Scan LP:</div>
<div class="data-wide"><input id="assignLP" autocomplete="off" type="tel"
ng-keypress="processKeystroke(event)"
ng-model="lpScan" placeholder="Scan LP" name="LPNumber"
required ng-pattern="/^\d+$/" ng-minlength="20" ng-maxlength="20"
ng-trim="true"/>
<div class="data-error"
ng-if="(checkInForm.LPNumber.$dirty || formValidate === 1) && checkInForm.LPNumber.$invalid">
LPNumber must be 20 digits
</div>
</div>
</div>
</form>
答案 0 :(得分:0)
首先,您的示例代码HTML中有一个破损的div。
<div class="data-item" ng-if="scanRequired && !lp.CheckedIn"
尝试在ng-change
input
上添加ng-change="watchInput()"
,然后在你的控制器中添加
$scope.watchInput = function() {
console.log($scope.lpScan);
}
检查您的控制台日志,看看您是否正在进行日志记录。如果是,那么只需将可操作的代码放在该函数中。
答案 1 :(得分:0)
看起来您每次触发submitLP函数时都会将$ scope.lpScan变量重置为空白,因此请在提交函数之外声明它:
Public Function list_of_points_on_arc(point_center As PointLatLng, point_arc_start As PointLatLng, point_arc_end As PointLatLng, direction As String) As List(Of PointLatLng)
'direction: CW - clockwise / CC - Counter Clockwise
Const radiusEarthKilometres As Double = 6371.01
'sets the resolution of arc
Dim elements As Integer = 20
'unknown point on arc, each ...element
Dim point_on_arc As PointLatLng
'List collects all points aon arc
Dim gpollist As List(Of PointLatLng) = New List(Of PointLatLng)
For i As Integer = 0 To elements
' ?????????????????????????????????????????????????????????
'calculates new point_on_arc based on following information
' - elements, point_center, point_arc_start, point_arc_end
' ...
'
' ...
'
' point_on_arc = New PointLatLng(on_arc_lat, on_arc_lon)
' ?????????????????????????????????????????????????????????
'adds point_on_arc to list
gpollist.Add(point_on_arc)
Next
'returns list of pointsLatLon
Return gpollist
End Function
这是一个例子: https://plnkr.co/edit/jcLsGoVFCXkmv1SnUdHl?p=preview