ng-messages

Custom validation directive using ng messages and typescript

半腔热情 提交于 2019-12-25 05:48:26
问题 I'm trying to build a module that has directive for custom validations and showing them using ng-messages The validations are done via regex. The error I am seeing is : Error: [$compile:ctreq] Controller 'ngMessages', required by directive 'ngMessage', can't be found! My code looks like this: Validation directive: module LoginModule { 'use strict'; /***** REGEX *****/ export class regExp { public ID_OR_PASSPORT = /^[0-9]{9}$/; public USERNAME_SINGLE_WORD = /^[A-Za-z0-9à-ú-_\.]{6,8}$/; public

Can't focus on Angular form text input after route change

不打扰是莪最后的温柔 提交于 2019-12-24 09:45:12
问题 I'm creating a form with Angular and Angular Messages. This form lies in a template that gets brought into the view with Angular Route. When I first load the form, everything functions properly. Then, when I load a different view and switch back to the form's view, I'm unable to focus on the text inputs. What's happening? The HTML <form name='submission' ng-submit='submit()'> <label class='text-input-group' for='name'> <div class='label'>Name</div> <input id='name' name='name' ng-model=

AngularJS Form Validation - Bind input to model eventhough there is input error

久未见 提交于 2019-12-13 01:06:05
问题 I have a form using the built in angularjs form validation and ng-messages. Look at this code. <div class="form-group" ng-class="{ 'has-error': form1.firstName.$invalid && form1.firstName.$touched }"> <label class="control-label">* First Name</label> <input name="firstName" ng-model="applicant.firstName" required ng-pattern="alpha" ng-minlength="2" ng-maxlength="30" type="text" class="form-control" /> <div class="help-block has-error" ng-messages="form1.firstName.$error" ng-if="form1

AngularJS: Hiding ng-message until hitting the form-submit button

人盡茶涼 提交于 2019-12-12 12:16:26
问题 This is a typical example of the use of ng-messages in AngularJS (1.x): <form name="demoForm"> <input name="amount" type="number" ng-model="amount" max="100" required> <div ng-messages="demoForm.amount.$error"> <div ng-message="required">This field is required</div> </div> <button type="submit">test submit</button> </form> see: http://jsfiddle.net/11en8swy/3/ I now want to change this example so the "This field is required" error only shows when the field is touched ( $touched ) or the user

angular ngMessages custom validation ng-message

扶醉桌前 提交于 2019-12-11 18:09:36
问题 I've got this custom validation function uiEmailEquals() { return { require: 'ngModel', link: function(scope, element, attrs, ngModel) { scope.$watch(attrs.uiEmailEquals, function() { ngModel.$validate(); }); ngModel.$validators.isEquals = function(value) { var email = scope.$eval(attrs.uiEmailEquals); if (!email || !value) { return false; } return (value === email); }; } }; } <input type="email" tabindex="4" name="cemail" class="form-control" ng-model="vm.data.cemail" placeholder="confirm

AngularJS: ngMessages not working with ng-options in select

谁都会走 提交于 2019-12-11 15:54:35
问题 I have seen few answers which were working for ng-repeat, but with ng-options I am facing issue. Problem : Want to show the error message required if the dropdown is touched and nothing is selected, I am able to do this with input fields. JS CODE $scope.personMap = [{ name:"Abc", id:"a"}, { name:"XYZ", id:"b"}, { name:"FGH", id:"c"}, { name:"TY", id:"d"} }] HTML <select name="inpName" ng-model="person.name" ng-options="i as i.name for i in personMap track by i.id" required> <option value=""

Angular : ng-message validation on submit click

与世无争的帅哥 提交于 2019-12-11 06:22:50
问题 I am working on application where I've one form and It should show validation error message for input fields on wrong input. My form will look like this - It should show error message if - Input field modified with wrong input Submit button clicked without modification in required input field. It should show error message as below - To achieve this I am using ng-message directive. It wil help me to show error message on $dirty of input field. But for Submit button I could not find correct way

Display validation messages when a button is clicked

痴心易碎 提交于 2019-12-11 04:46:04
问题 I think what I want to achieve is quite simple. Let's have a form with a required field, a select for instance (I've also tried it with an input and it's exactly the same situation anyway). I want to display the ng-messages only when a button is clicked. If the form field was touched before clicking the button, it works fine. But I cannot do it if the form field is $untouched . I've solved it setting programatically $touched to the form field, but I'm wondering if there is any way to solve it

angular ng-messages only showing when $touched is true

风流意气都作罢 提交于 2019-12-10 12:32:07
问题 I am not doing anything too special. I have an input I want validated with every key stroke. If validation fails, display the error. Do not wait for the blur event to trigger the $touched. I thought this was the default case, but apparently it is not. I am using angular materials along with angular messages. I am doing this for capslock detection. The markup: <form name="primaryLogin" novalidate> <md-content layout-padding layout="column"> <md-input-container flex> <label>Login ID</label>

Ngmessages Uncaught TypeError l.module(…).info is not a function

∥☆過路亽.° 提交于 2019-12-07 15:15:41
问题 I've installed Angular-Messages to my Ionic V1 App but I cannot make it work. Error: Uncaught TypeError: l.module(...).info is not a function at angular-messages.js:267 at angular-messages.js:6 This is my index.html: <!-- ionic/angularjs js --> <script src="lib/ionic/js/ionic.bundle.js"></script> <!-- cordova script (this will be a 404 during development) --> <script src="cordova.js"></script> <script src="js/sha1.js"></script> <script src="lib/ionic-material/dist/ionic.material.min.js"><