angularjs-ng-form

Set angularjs input directive name as a variable

故事扮演 提交于 2019-12-11 09:48:41
问题 I'm trying to set an input like <form name="myForm"> <input name="{{ name }}"/> </form> It works in the dom. I see <input name="whatever_name_is_set_to"/> However in my ngForm I have $scope.myForm: { {{ name }}: { } } Doh' Why am I doing this? I'm trying to create a directive so that I can build my forms programmatically. Then I can do something like <div my-field name="credits" field="course.credits" field-options="courseOptions.credits" title="Credits" ></div> Plunker 回答1: Updated 2017-03

Passing Information to Directive to Match Passwords

房东的猫 提交于 2019-12-11 05:27:16
问题 I'm trying to add an errors to my floating placeholder labels when certain conditions are met in my controller However, I'm not sure the best way to go about this and my current implementing doesn't seem to be detecting the attribute change in the directive (custom-error stays set to "test"). Here's what I've got right now: HTML: <input type="password" float-placeholder custom-error="test" placeholder="Confirm password" required name="passwordSecond" id="passwordSecond" ng-model="vs

ng-form inside ng-repeat with submit button outside of ng-repeat

笑着哭i 提交于 2019-12-10 19:24:15
问题 I've this code: <div class="row" ng-repeat="input in inputs | filter:inputNumber"> <ng-form name="form1"> <div class="col-xs-3"> <div class="form-group"> <input ng-model="inputs.number[$index]" type="number" name="number$index" class="form-control" placeholder="" min="1" max="9999" required /> <small class="label label-danger" data-ng-show="submitted && form1.number$index.$error.required">required</small> <small class="label label-danger" data-ng-show="submitted && form1.number$index.$error

Why a “preLink” function is used in angular directive `ngForm`, instead of regular “postLink” function?

允我心安 提交于 2019-12-08 12:41:57
问题 Inside angular.js, in ngForm (form) directive definition, compile function returns only a preLink function. Why it should be preLink instead of common postLink ? The following code is from angular.js master branch: var formDirective = { name: 'form', restrict: isNgForm ? 'EAC' : 'E', controller: FormController, compile: function ngFormCompile(formElement) { // Setup initial state of the control formElement.addClass(PRISTINE_CLASS).addClass(VALID_CLASS); return { pre: function ngFormPreLink

Why is $timeout needed when dynamically nesting ng-form in Angular to ensure child form links with parent form?

假如想象 提交于 2019-12-07 06:31:25
I cannot seem to avoid the need to generate dynamic sub forms in the application I am working on. The sub form is working as expected and the sub form shows $invalid=true when one or more of it's inputs are invalid. The parent form however has $invalid=false. I have seen people achieve nested forms where invalid sub forms invalidate the parent form, but I can't seem to do it dynamically without wrapping the dynamic compiling of the sub form in a $timeout. See Plunker HERE In the above link I have recreated the scenario. I have three forms. The parent form, a sub form created at the same time

AngularJS multiple forms with ng-repeat validation

独自空忆成欢 提交于 2019-12-07 03:46:26
问题 I am using ng-form as a parent form and child mg-forms for validation with ng-repeat. <div ng-form="form"> <div ng-repeat="field in fields"> <div ng-form="subform"><input...></div> </div> </div> And validating like this: if ($scope.form.subform.$invalid && !$scope.form.subform.$error.required) { // Do something... } (this is very simplified example, I have more different subforms for different input types and with different names, e.g. input[text] is named as a TextForm, input[numeric] is

Google-like search box with an AngularJS directive

别说谁变了你拦得住时间么 提交于 2019-12-06 03:33:15
问题 I am writing an application which UI wise is almost exactly like Google. I arrive at landing page I have a search box which on submit directs you to results page. Here you have the same search box and other directives in which you can switch between modes: eg. web, image. Currently I have: on landing page: form with action="results.html" which passes the parameters in the url. <form name="search" role="form" action="results.html"> <div class="input-group input-group-search"> <input type="text

AngularJS multiple forms with ng-repeat validation

筅森魡賤 提交于 2019-12-05 07:50:51
I am using ng-form as a parent form and child mg-forms for validation with ng-repeat. <div ng-form="form"> <div ng-repeat="field in fields"> <div ng-form="subform"><input...></div> </div> </div> And validating like this: if ($scope.form.subform.$invalid && !$scope.form.subform.$error.required) { // Do something... } (this is very simplified example, I have more different subforms for different input types and with different names, e.g. input[text] is named as a TextForm, input[numeric] is NumericForm etc.) Everything works as expected if there is only on field. But if ng-repeat generates

Google-like search box with an AngularJS directive

混江龙づ霸主 提交于 2019-12-04 07:15:45
I am writing an application which UI wise is almost exactly like Google. I arrive at landing page I have a search box which on submit directs you to results page. Here you have the same search box and other directives in which you can switch between modes: eg. web, image. Currently I have: on landing page: form with action="results.html" which passes the parameters in the url. <form name="search" role="form" action="results.html"> <div class="input-group input-group-search"> <input type="text" class="form-control" ng-model="blab" name="q" required> <span class="input-group-addon"> <button

ngForm simple example in angular 6 with select box

情到浓时终转凉″ 提交于 2019-12-01 20:46:06
Angular 6 form validation simple example. With email validation and select box(drop down).ngForm simple example in angular 6 with select box Use ngForm. Import it your component.module.ts(module file) import { FormsModule } from '@angular/forms'; Add it your component template <form role="form" (ngSubmit)="f.form.valid && onSubmit()" #f="ngForm" novalidate> <select name="name_id" [(ngModel)]="model.name_id" #name_id="ngModel" [ngClass]="{ 'is-invalid': f.submitted && name_id.invalid }" required> <option value="" disabled selected>Select Name</option> <option *ngFor="let name of allnames"