我有可能看起来像一个noob问题。我有一个简单的Angular控制器来控制页面上的表单。表单的标记非常简单。当我加载页面时,我看到表单呈现两次,而不是一次。我在这里做错了什么?HTML角度形式出现两次
这里是我的HTML:
<div class="container">
<div class="col-lg-12">
<div class="row">
<h2>CREATE</h2>
<div class="col-lg-6 col-lg-offset-2">
<div class="form-container" ng-controller="NewPostQuestionCtrl">
<form accept-charset="UTF-8" name="form.postQuestionForm" ng-submit="createPostQuestion(postQuestion)" class="new_post_item" novalidate>
<input name="utf8" type="hidden" value="✓">
<input name="authenticity_token" type="hidden" ng-model="postQuestion.token" ng-init="postQuestion.token='<%= form_authenticity_token %>'">
<input name="employer_id" type="hidden" ng-model="postQuestion.employer_id" ng-init="postQuestion.employer_id='<%= current_employer.id %>'">
<div class="form-group">
<label>Question</label>
<textarea class="question-textbox" name="question" ng-model="postQuestion.question" required></textarea>
</div>
<div class="form-group">
<label>Image</label>
<input class="" name="image" ng-model="postQuestion.image" type="file" required>
</div>
<div class="form-group">
<label>Publish Question</label>
<select class="" name="published" ng-model="postQuestion.published" required>
<option value="true">Publish</option>
<option value="false">Don't Publish</option>
</select>
</div>
<input class="submit-btn" name="commit" type="submit" value="Publish Post" ng-disabled="form.postQuestion.$invalid">
</form>
</div>
</div>
</div>
</div>
</div>
这里是我的控制器:
app.controller('NewPostQuestionCtrl', ['$scope', '$http', function($scope, $http) {
$scope.form = {}
$scope.postQuestion = {
token: $scope.token,
employer_id: $scope.employer_id,
question: $scope.question,
published: $scope.published,
image: $scope.image
};
}]);
谢谢!