零件's的形式没有被呈现-AngularJS

Part's of form not being rendered - AngularJS

本文关键字:-AngularJS 零件      更新时间:2023-09-26

我似乎不明白为什么表单的"开始"answers"结束"部分没有被呈现。这是我第一次使用AngularJS,在网上学习了很多教程后,我习惯于用文章示例来创建meanjs生成器。然后,我以文章为例,试图将其移植到这个调度问题上。不过,这真的没关系,我只想知道为什么表单中的最后两个输入没有在我的视图中呈现。

非常感谢任何帮助

以下是我的观点代码:

<section data-ng-controller="SchedulesController">
    <div class="page-header">
        <h1>New Schedule</h1>
    </div>
    <div class="col-md-12">
        <form name="scheduleForm" class="form-horizontal" data-ng-submit="create()" novalidate>
            <fieldset>
                <div class="form-group" ng-class="{ "has-error": scheduleForm.title.$dirty && scheduleForm.title.$invalid }">
                    <label class="control-label" for="title">Title</label>
                    <div class="controls">
                        <input name="title" type="text" data-ng-model="title" id="title" class="form-control" placeholder="Title" required>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label" for="content">Content</label>
                    <div class="controls">
                        <textarea name="content" data-ng-model="content" id="content" class="form-control" cols="30" rows="10" placeholder="Content"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label" for="start">Start</label>
                    <div class="controls">
                        <input name="finish" value="" type="date" data-ng-model="start" class="form-control" required>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label" for="finish">Finish</label>
                    <div class="controls">
                        <input name="finish" value ="" type="date" data-ng-model="finish", class="form-control" required>
                    </div>
                </div>
                <div class="form-group">
                    <input type="submit" class="btn btn-default">
                </div>
                <div data-ng-show="error" class="text-danger">
                    <strong data-ng-bind="error"></strong>
                </div>
            </fieldset>
        </form>
    </div>
</section> 

这是我的控制器的代码:

'use strict';
angular.module('schedules').controller('SchedulesController', ['$scope', '$stateParams', '$location', 'Authentication', 'Schedules',
    function($scope, $stateParams, $location, Authentication, Schedules) {
        $scope.authentication = Authentication;
        $scope.create = function() {
            var schedule = new Schedules({
                title: this.title,
                content: this.content,
                start: this.start,
                finish: this.finish
            });
            schedule.$save(function(response) {
                $location.path('schedules/' + response._id);
                console.log('hola!');
                $scope.title = '';
                $scope.content = '';
            }, function(errorResponse) {
                $scope.error = errorResponse.data.message;
            });
        };
        $scope.remove = function(schedule) {
            if (schedule) {
                schedule.$remove();
                for (var i in $scope.schedules) {
                    if ($scope.schedules[i] === schedule) {
                        $scope.schedules.splice(i, 1);
                    }
                }
            } else {
                $scope.schedule.$remove(function() {
                    $location.path('schedules');
                });
            }
        };
        $scope.update = function() {
            var schedule = $scope.schedule;
            schedule.$update(function() {
                $location.path('schedules/' + schedule._id);
            }, function(errorResponse) {
                $scope.error = errorResponse.data.message;
            });
        };
        $scope.find = function() {
            $scope.schedules = Schedules.query();
        };
        $scope.findOne = function() {
            $scope.schedule = Schedules.get({
                scheduleId: $stateParams.scheduleId
            });
        };
    }
]);

嗯。。。伙计们。。。。我不知道为什么会这样,我身上的一切都告诉我这不是问题,但:

通知行<input name="finish" value ="" type="date" data-ng-model="finish", class="form-control" required>

","是一个错误(我写了一个脚本,将文章中的所有内容都移植到了时间表中,保留了代码结构,只是更改了所有提到[Aa]文章{s}->[Ss]时间表{s}的内容,而这是遗留下来的(出于某种原因,不知道它是从哪里来的)。不管怎样,我删除了评论并运行了grunt build && grunt test && grunt,它起了作用。我现在得到了正确的渲染。