everyone.
I am developing app with angular and I am using Angular material for UI.
I know about angular validation
https://angular.io/docs/ts/latest/cookbook/form-validation.html
How can I validate md-select ?
You can validate md-select the same way it's shown in the documentation. The main idea is to create a reference #someName and the use that reference to do the validation. There are six controls that Angular provides: touched, untouched, dirty, pristine, valid and invalid.
I created a Plunker demo for you with the dirty validation for md-select.
You can read more about validation in the "Track control state and validity with ngModel" section, here: https://angular.io/docs/ts/latest/guide/forms.html
Related
Consider this html
<input type="text" name="txt" ng-model="ctrl.txt">
I want to write my own form-validation mechanism in an Angular 1 app. Is it a good practice to base the validation on the value of the ngModel that is bind to the input element instead of the actual input value (as it done in the built-in angular form validator)?
In other words, is there a reason to avoid doing that (for any input type)?
(PS I'm familiar with the standard Angular form validation. No need to suggest using it)
Maybe is worth doing a small introduction to validation.
Front end validation is no validation, if you want to persist your data to a server.
It is best practice to validate inputdata server side before saving there somewhere.
In case you whish to "prevalidate" the user input to avoid a future reiteration because of a wrong input, then best practice is to use the standard features of Angular and not reinvent the wheel with custom controller function (even if it is possible).
angular forms guide
I hope it helps.
Can I disable spring MVC to generate hidden field for checkbox. I'm using Thymeleaf templates.
Thanks!
This is a fairly old question, but I just ran into this posting a Spring form that contained checkboxes with a GET action. My work-around also uses jQuery, which was not tagged in this question, but it did achieve the desired result.
The _checkbox hidden field was showing in the URL as a query string parameter. I ended up using jQuery to remove the Spring-generated hidden fields at page load, which cleaned up the URL on submit. I did not see any adverse behavior on the server side.
I've been having some trouble getting a decent explanation of what ui-sref is actually doing in angular.
In HTML href is hyperlink reference, so does sref mean script reference?
ui-sref stands for UI-Router state reference. It's a way to change states/state params (as defined in using the $stateProvider in a config block using the ui.router module for AngularJS. You can read the ui-sref documentation here.
I'm very new to Angular and I've been doing tutorials and reading books. I'm trying to get an autocomplete from a JSON result. I got the JSON result to iterate over a table, but I need to be able to search with autocomplete based off of that same JSON result.
I have a Plnkr below. Any help would be greatly appreciated.
http://plnkr.co/edit/VObrSPu94rS3dGyVqaXk
If you pop open your developer console, you'll see that there is an error being thrown from your ngAutocomplete.js file. It looks like that directive is designed to be used for Google Places and is expecting you to have a Google library loaded as well.
You probably want to look for a more generic autocomplete directive. The only one I've used is the typeahead included in the Angular UI Bootstrap project, but there are a number of autocomplete modules on the Angular Modules site (the one you are using is the second one listed) that may work for you.
As Sean says, Angular UI Bootstrap (Typeahead) is a good option.
Here is a specific tutorial for that feature from my project.
I'm developing a project using Spring 3.0.
I have a form with several submit buttons.
What I would like to do is to have different validation requirements depending on the pressed button.
How do I do this? An example would be great.
Thanks
You can have multiple implementation of Spring Validator. And depending on the button clicked you can call validate method of required validator implementation from controller.
Here is a example of validation using spring validator.