81 questions
0
votes
0
answers
49
views
Multiple validation is not working properly in template driven form
I having issue multiple validation is not working properly. For example validate1 method checking input is empty or not , validation2 method checking name1 and name2 value are equal or not equal. ...
1
vote
1
answer
61
views
Formatters and Parsers , ng-true-value & ng-false-value directive for Angular make workable
Currently I am created two directive to project . But one directive useed for if checkbox is checked , I will get 1, if checked is false i will get 0. Another Directive is used for convert value &...
1
vote
1
answer
71
views
Angular Nested Form ngModel meaning
Given the following code snippet:
@Component({
selector: 'app-editor',
templateUrl: './editor.component.html',
styleUrls: ['./editor.component.scss'],
providers: [{
provide: ...
1
vote
2
answers
75
views
Angular Template-Driven Form: Validate Password Field Only After User Interaction
I have a form:
<input
type="password"
id="password"
name="password"
ngModel
#password="ngModel"
...
1
vote
1
answer
46
views
Change value of dropdown from another dropdown in Angular 17
I'm trying to setup the form in such a way that when someone selects Mr in the first dropdown, the value changes to male in the second dropdown.
Likewise, if someone chooses Miss/Mrs, the 2nd dropdown ...
2
votes
1
answer
52
views
select first option of dropdown on change event in angular
<select [(ngModel)]="profile.type" name="type"(change)="selectPhoneType($event,mailCreate,'phone4_Value')">
<option value="">...
0
votes
2
answers
151
views
Angular - edit textbox in grid to update row value
I'm trying to give user the ability to update the quantity of their selection before product checkout. The code below allows only 1 character in the textbox. What changes can I make to allow user ...
2
votes
1
answer
50
views
Fill Textboxes with Database Values on a Textbox Value Changed
My requirement is to fill textboxes with their corresponding value from database when a change is made in name textbox. For instance, if the value Mary is enter in name textbox then its corresponding ...
1
vote
1
answer
3k
views
Angular 16 - error NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'
I have the above error message when I try to use two-way binding in a Angular application.
<form>
<input type="email" class="form-control" id="email" name="...
1
vote
0
answers
172
views
With Angular 16, why errors from async validators aren't displayed?
I have a weird behavior with async validators from Angular.
Here's the context (this is an example, not the best use case here but that's not the issue ^^) :
I have a form with a ngModelGroup inside.
...
0
votes
1
answer
335
views
Dropdown menu in template-driven form doesn't validate required property on submit
I have a template-driven form in my Angular application that includes a dropdown menu (select element). I want to validate the dropdown menu to ensure that a value is selected before the form is ...
0
votes
1
answer
586
views
How to create a Template driven formArray in Angular?
I have a fix number of checkbox which I am binding using for loop.
<ul>
<li *ngFor="let chk of checkboxes">
<input type="checkbox" [id]="chk.id"...
0
votes
0
answers
682
views
how to show the duplicate error message in particular row based on duplicate input using angular12
here i am using template forms for binding the values under array and there is inline edit available for each row, issue is that, if i am giving duplicate for 3 rows under order number or the name, it ...
2
votes
1
answer
165
views
Unexpected Angular ExpressionChangedAfterItHasBeenCheckedError in template-driven form
I have a very simple Angular Component as follow:
import { Component } from '@angular/core';
@Component({
selector: 'test-view',
template: `
<div [ngStyle]="{ 'background-color': m....
3
votes
0
answers
319
views
How to use Angular 2 Reactive form with ng-content
I have "FormWrapper" Component like that
<form [formGroup]="wrapperForm">
<ng-content></ng-content>
</form>
and AppComponent like that:
<app-form-...
1
vote
1
answer
325
views
angular 14 template driven Cannot read properties of undefined (reading 'control')
I need to refer my form to do some think. This my hmtl code is:
<form #formField="ngForm">
<div class="row">
<div class=&...
0
votes
0
answers
537
views
How to Pass data from one search box to another search box in same component without losing input value in angular 13
I need to show the result in second component, the first component is rendered in the second component at the same time i need the user input value to be displayed in the second component for further ...
0
votes
0
answers
1k
views
Angular multiple forms each with its submit button
I want to have two forms on a page, each with their own submit button and validation.
However, when I try and submit the 1st form the validation for the 2nd form triggers (and vice versa). Is there a ...
0
votes
2
answers
4k
views
mat-error doesn't show in mat-autocomplete and in mat-form-field
my purpose is show an error when the user doesn't put a value. I know that above example doesn't have a lot of sense, but I don't read the error also if the programs must show. the code is this:
<...
1
vote
0
answers
1k
views
Wrap a material component (mat-select) inside a component of mine
I'm trying to use mat-select of Angular Material 11.2.12.
Since I need to make mat-select do some stuff (filter, select/deselect all) besides its default behavior, I need to put it inside a component ...
1
vote
1
answer
143
views
How to raise mat-error in angular for just some specific field?
I have a form where are sub categories and save button calls mat-error correctly for all the fields in all categories in once correctly if nothing entered. But I also have add button for each category ...
0
votes
1
answer
617
views
how to get Attribute associated Angular FormControl
I have multiple angular forms which are generated inside a ngFor loop as follows. and each form is a wizard step which a user can move forward by completing the form individually. in the form input ...
1
vote
0
answers
1k
views
how can assign value "$event" to template variable?
since I use several similar mat-inputs inside a template form, I define an ng-template for these mat-inputs and refer to it via *ngTemplateOutlet and also pass related data to the template as bellow:
...
3
votes
2
answers
5k
views
angular dynamic input populates same value
Im trying to build a form wherein you can create another field of input on clicking an add button. The problem is that same value gets populated for each row input. As you can see from the below image,...
2
votes
2
answers
4k
views
How do I handle undefined properties from the html in my Angular application before I receive data from my controller?
When my Angular component HTML renders. I will get lots of errors that look like this
ERROR TypeError: Cannot read properties of undefined (reading 'someProperty')
In my HTML page, I have lots of ...
0
votes
2
answers
913
views
Behavior of ngModel vs formControlName for radio elements
While working with validating same radio input elements with two different approaches viz. template-driven-form and model-driven-form, I am stuck with the scenario where for template-driven-form, ...
0
votes
0
answers
236
views
Issue with setValue of Angular template forms? How to set a value for a template form?
I'm trying to make a form like this;
<form #testForm="ngForm" (ngSubmit)="onSubmit(testForm)" novalidate>
<!-- X-Value -->
<div ngModelGroup="xValue&...
2
votes
1
answer
975
views
Angular - input wrapped in custom component not working in template driven form
Just like the title says, if I wrap an input in my custom component, it's not being picked up by Angular's template form. Here's the stackblitz
Here's some code from StackBlitz
app.component.html
<...
1
vote
1
answer
1k
views
How to set the default values of template-driven form after edit but not saved in Angular without formgroup?
If I open the form and change the input field 'city' and click cancel. After that if I open the form again, the defualt value is changed. How to get that default value in the form field?
component
...
0
votes
0
answers
253
views
the select option value changes for all other select options
<nb-select [(ngModel)]="selectedOption"
(click)="getProdDetails(p.ProductName,p.Brand)" ngDefaultControl>
<nb-option [value]="p.Size" class="text-...
0
votes
1
answer
111
views
data is not showing in dropdown template driven form
there is a template-driven form and within this form, there is a dropdown. I want to show data from the backend to the dropdown.
Here data is coming from the backend in appliesWhenData.
<form #...
0
votes
1
answer
1k
views
Two way binding in angular 9 forms
Two way binding in angular 9 form
I tried using [(ngmodel)] in form but it gives error This is depricated in angular 6 and above versions
2
votes
2
answers
9k
views
Angular Reactive Forms: how to pre load form inputs with information
I am trying to create a forum within my website. After struggling to implement using template driven forms, I decided to switch to Reactive forms. I have been switching between the two approaches ...
0
votes
1
answer
492
views
Selected option not shown (angular, html)
I have the following angular template form :
<label for="operationType" class="form-control">Operation</label>
<select name="operationType" [(...
4
votes
1
answer
2k
views
When to use template driven & reactive forms in Angular
I have read a lot of articles about the differences about the 2 types of forms in angular but nowhere found practical examples. So, if I have a table, and only a checkbox to select rows, is there any ...
1
vote
0
answers
248
views
Mat error is not getting displayed when using with ngModel
I am using mat error in the below way
<mat-form-field appearance="outline">
<input matInput
[ngModel]="_control.control.value"
(...
0
votes
1
answer
186
views
Template driven input and reactive input not working the same in component DOM test
I use template driven input and can not get its value in unit test unlike of reactive input.
Here are two same components one implemented with template driven approach and anoter one with using of ...
3
votes
1
answer
2k
views
Listen for template driven form changes in Angular 10
I have a template driven form in my angular 10 app that I am trying to listen for changes to so that I can show an 'changed, please submit updates' message to the user.
HTML
<form (ngSubmit)="...
2
votes
1
answer
268
views
how to validate template driven forms in angular number sign "#"
Hello guys? how can i Validate #permissionInput if there's a value, btw this is angular.
<input
#permissionInput
type="text"
...
2
votes
3
answers
4k
views
How to validate Template-Driven-Forms on children components in angular
I am working on Angular 10.
Its been 3 days that I have a problem with angular template-driven and reactive forms.
What I want to do: Create a complex form with many child components (in order to ...
3
votes
1
answer
2k
views
angular custom component for both template and reactive form
I'm trying to create a custom component (a customized autocomplete field) but I want to work for both reactive forms and template forms
So sometimes the value will come through [(ngModel)] and ...
3
votes
2
answers
5k
views
How to manually set an Angular template driven form as invalid in angular9
I want to manually set the EmployeeForm as Invalid from the .ts file. Here EmployeeForm is a Template driven form.
I have tried to do the following but it didn't work.
this.EmployeeForm.setErrors({ '...
0
votes
1
answer
962
views
ngx-bootstrap template modal with template driven form, submit issue
i have template ref modal with template driven form inside it.
when i submit the form, all form value gets printed on url
http://localhost:4200/admin/users?userName=test&[email protected]&...
0
votes
1
answer
2k
views
Angular NgForm.setValue({}) with optional fields
I have a Template driven form in angular,
on which i want to populate valuees when i click on a product.
The fields 'description' and 'imageUrl' might be undefined which break my form if i don't take ...
0
votes
1
answer
1k
views
How to add/remove or show/hide textbox in an Angular form according to dropdown value
On selecting a particular item from this open dropdown I want the textboxes to be shown in the form
Each of these dropdown value has certain properties which are being fetched from database.
This is ...
0
votes
0
answers
581
views
Angular template-driven form custom validation
I need to write the custom validator for the Angular template-driven form where one any non-empty input would be sufficient to make the form valid.
Consider the following Angular form with the two ...
0
votes
0
answers
410
views
I want to create a template driven form in my ionic app with validation it gives error
Whenever I am using ngModel with id it gives an error. If I don't use this then it shows an error that invalid is not any property. Please tell me where I am going wrong.
<form #loginform="...
0
votes
1
answer
2k
views
Angular Material Stepper With Mat-Select implementing default value
I would like to have a default value shown with a mat-select in a stepper from Angular material.
[Edit] you cannot use formControlName with two-way binding. I ended up initializing the value in the ...
1
vote
1
answer
2k
views
Template reference variables: assigning ngForm and ngModel
I am learning Angular on Pluralsight and I have a question regarding a course I am taking currently.
I am confused on the reasoning behind template reference variables when they are assigned a value. ...
0
votes
1
answer
815
views
create form from http request data
I am new to angular so still learning it, it might be simple use case but so far i have been trying to implement it but unable to do it so asking here. I am making an http requests and based on the ...