我有以下形式(導軌)
= form_for([@debate,@argument], html: { class: "form-horizontal", role: "form" , "ng-submit"=>"addArgument('support',$event)", novalidate: true, name: "argumentformsupport"}) do |f|
- if @argument.errors.any?
.alert.alert-danger.alert-dismissable role="alert"
button.close type="button" data-dismiss="alert"
span aria-hidden="true"
| ×
span.sr-only
| Close
h4= "#{pluralize(@argument.errors.count,"error")} prohibited this argument from being saved:"
ul
- @argument.errors.full_messages.each do |msg|
li= msg
= f.hidden_field :side, :value=>side, "ng-model"=>"argument['support'].side"
.form-group
.col-sm-12
= f.text_area :content, class: "form-control", "ng-model"=>"argument['support'].content", required: true, "ng-minlength"=>"100", "ng-maxlength"=>"4000"
textarea.form-control ng-model="argument['support'].content" name="content" required=true ng-minlength="100" ng-maxlength=4000
<div ng-messages="argumentformsupport.content.$error" style="color:maroon" role="alert">
<div ng-message="required">Please type the argument</div>
<div ng-message="minlength">Your field is too short</div>
<div ng-message="maxlength">Your field is too long</div>
</div>
.form-group
.col-sm-4
= f.submit class: "btn btn-success"
.col-sm-3
button.btn.btn-danger type="button" ng-click="debcon.toggleArgumentForm('support')" Cancel
以下是我的應用程序的js代碼
var debateApp=angular.module("debate",['ng-rails-csrf', 'yaru22.angular-timeago'])
debateApp.controller("DebateController",["$scope","$http",function($scope,$http){
....
}
黃氏的消息的事情並不在所有的工作。所有消息都可見。我添加了角度消息依賴性,但所有消息仍然可見。
我還檢查argumentformsupport.content。$錯誤對象。其空
您正在使用的角版本? –
我正在使用angular 1.4.5 –
你在哪裏添加了依賴關係?在你的例子中缺少它。你可以設置一個重啓器來演示這個問題,這樣我們可以調試它嗎? –