Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 来自Svc的数据未建模到视图元素AngularJS中_Javascript_Angularjs - Fatal编程技术网

Javascript 来自Svc的数据未建模到视图元素AngularJS中

Javascript 来自Svc的数据未建模到视图元素AngularJS中,javascript,angularjs,Javascript,Angularjs,我有一个视图,它被建模为将数据传递到数据库的函数。这一切都在工作,我看到数据在调用时返回,但它返回时并没有预先填充视图中的字段。这件事让我头痛了好一阵子。一切都被正确地建模(据我所知) 我已经在Chrome中浏览了下面的JS代码,并从data.XXX返回中看到了分配给我的$scope变量的数据 但是,在加载完成后,它并没有预先选择我的单选按钮或用数据填充字段。非常感谢您的帮助 以下是视图: <div class="notification-container"> &l

我有一个视图,它被建模为将数据传递到数据库的函数。这一切都在工作,我看到数据在调用时返回,但它返回时并没有预先填充视图中的字段。这件事让我头痛了好一阵子。一切都被正确地建模(据我所知)

我已经在Chrome中浏览了下面的JS代码,并从data.XXX返回中看到了分配给我的$scope变量的数据

但是,在加载完成后,它并没有预先选择我的单选按钮或用数据填充字段。非常感谢您的帮助

以下是视图:

<div class="notification-container">
        <form name="notificationForm" class="form-horizontal" ng-submit="saveQrNotifications()">
        <div class="list-unstyled">
            <input id="text" ng-model="NotificationMethods.NotificationMethodId" ng-change="notifyVisible()" name="text" type="radio" ng-value="1001"> Text Message<br>
            <input id="email" ng-model="NotificationMethods.NotificationMethodId" ng-change="notifyVisible()" name="email" type="radio" ng-value="6"> Email<br>
            <input id="voice" ng-model="NotificationMethods.NotificationMethodId" ng-change="notifyVisible()" name="voice" type="radio" ng-value="1003"> Voice<br>
            <input id="nocontact" ng-model="NotificationMethods.NotificationMethodId" ng-change="notifyVisible()" name="nocontact" type="radio" ng-value="1000"> Do Not Contact<br>
        </div>

        <div class="col-md-12 notification-fields" ng-show="notifyFieldVisibility == true">
             <div class="col-md-12" ng-if="NotificationMethods.NotificationMethodId == '1001'">
                <label class="notication-input">Text Number</label>
                    <span class="clearfix"></span>
                    <input class="form-control area-code" type="text" ng-model="NotificationMethods.NotificationTextAreaCode" placeholder="(555)" required>
                    <input class="form-control phone-number" type="text" ng-model="NotificationMethods.NotificationTextPhoneNumber" placeholder="555-5555" required>
            </div>
            <div class="col-md-12" ng-if="NotificationMethods.NotificationMethodId == '6'">
                <label class="notification-input" for="email">E-mail Address
                    <input class="form-control" id="email" name="email" type="text" ng-model="NotificationMethods.NotificationEmailAddress" placeholder="ex.me@example.com" required>
                </label>
            </div>
            <div class="col-md-12" ng-if="NotificationMethods.NotificationMethodId == '1003'">
                <label class="notication-input">Voice Number </label>
                <span class="clearfix"></span>
                    <input class="form-control area-code" type="text" ng-model="NotificationMethods.NotificationVoiceAreaCode" placeholder="(555)" required>
                    <input class="form-control phone-number" type="text" ng-model="NotificationMethods.NotificationVoicePhoneNumber" placeholder="555.5555" required>
                <label class="small">Ext.</label>
                <input class="form-control extension" type="text" ng-model="NotificationMethods.NotificationVoiceExtension" placeholder="555">
            </div>
            <span class="clearfix"></span>
            <div ng-show="notifyLoading" class="text-center" style="margin-top: 10px;">
                <i class="fa fa-spinner fa-spin"></i> Saving...
            </div>
            <div class="col-md-12">
                <button type="submit" class="btn btn-primary notification-btn">Save Notifications</button>
            </div>

        </div>
        </form>

</div>

我明白了。我在ng include中使用的视图上声明控制器。删除它并让视图从周围视图继承控制器解决了这个问题。

你能创建JSFIDLE吗?这需要一点时间,我真的只是拉了上面显示的这一部分的动作元素,ng if/show元素涉及了很多,我必须为JSFIDLE重构这些元素。
if (data.StatusCode == "SUCCESS") {
            $scope.refill = data;
            //$scope.deliverTypes = data.DeliveryTypes;
            $scope.showError = false;
            $scope.submitRefill = true;
            $scope.findRefillStatus = userMessageService.QuickRefillMessage(data.Prescriptions[0]);
            $scope.isRefillable = data.Prescriptions[0].IsRefillable;
            $scope.prescription.noPrescription.$valid = true;
            $scope.loading = false;
            $scope.NotificationMethods.NotificationEmailAddress = data.NotificationEmailAddress;
            $scope.NotificationMethods.NotificationMethodId = data.NotificationMethodId;
            $scope.NotificationMethods.NotificationTextAreaCode = data.NotificationTextAreaCode;
            $scope.NotificationMethods.NotificationTextPhoneNumber = data.NotificationTextPhoneNumber;
            $scope.NotificationMethods.NotificationVoiceAreaCode = data.NotificationVoiceAreaCode;
            $scope.NotificationMethods.NotificationVoicePhoneNumber = data.NotificationVoicePhoneNumber;
            $scope.NotificationMethods.NotificationVoiceExtension = data.NotificationVoiceExtension;
        }