ruby on rails - How do i display validation error from controller using angularjs? -
I'm new to angular railways and I'm completely confused, I'm trying below code and do not know I'm sure it's right.
Now when I'm checking less than the date of checkin, the error is not displayed. Can anyone tell me in the right direction? A Both are outside the scope of their controllers. Since you are trying to compare the value of both In addition, the way you are using the index.html
& lt; Div class = "input-group" ng-controller = "validation controller" & gt; & Lt; span class = "input-group-connector" & gt; & Lt; Span class = "glyphicon glyphicon-calendar" & gt; & Lt; / Span & gt; & Lt; / Span & gt; & Lt;% = text_field_tag: checkand, param [[checkdate]] :: placeholder = & gt; 'Select Date' ,: Category = & gt; 'Form-Control Datapicator Input-LG': Required = & gt; Truth, "NG-Model" = & gt; "Checkin.date"%> & Lt; / Div & gt; & Lt; div class = "input-group" ng-controller = 'validation controller' & gt; & Lt; span class = "input-group-connector" & gt; & Lt; Span class = "glyphicon glyphicon-calendar" & gt; & Lt; / Span & gt; & Lt; / Span & gt; & Lt;% = text_field_tag: checkoutdate, parameters [: checkoutdate],: placeholder = & gt; 'Select Date' ,: Category = & gt; 'Form-Control Datapicator Input-LG': Required = & gt; Truth, "NG-Model" = & gt; "Checkout.date"%> & Lt; / Div & gt; & Lt; P ng-show = 'isInvalidDate ()' & gt; The checkout date can not be less than the checkin date & lt; / P & gt;
Validation controller.js
App.controller ('Validation Controller', ['$ scope', function ($ Scope) {$ Scope.isInvalidDate = function () {return $ scope.checkout.date & lt; $ scope.checkin.date;}}]));
App.js
var app = angular Module ('app', []);
controller only works on this DOM-element and its Children are declared.
& lt; P ng-show = 'isvalidDate ()' & gt; The checkout date can not be less than the checkin date & lt; / P & gt;
input s, D to both of them and
p Need to keep elements inside the element with the
ng-controller attribute.
ng-controller attributes, you think that you consider it a singleton. In your case, you have two examples of
administrator , one of them knows about check-date and the other person knows about the checkout date. None of them will really be able to do validity.
Comments
Post a Comment