Using two separate ngModel directives in a parent component to control individual child component elements

One of the challenges I am facing is how to handle a child component with 2 input text-fields simultaneously. Both of these fields require ngModel validation in the parent component. Additionally, both inputs are mandatory and need to be checked using !form.valid. Is it possible to use an object for [ngModel]="name" to achieve this?

If you would like more information on the *.ts files, please refer to this StackBlitz demo

child:

<mat-form-field>
    <input matInput type="password" 
           name="{{inputNamePass}}" 
           [(ngModel)]="modelPass" 
           (ngModelChange)="modelChange.next($event)" 
           required pattern=".....">
</mat-form-field>
<br><br>
<mat-form-field>
    <input matInput type="password" 
              name="{{inputNamePassConfirm}}" 
              [(ngModel)]="modelPassConfirm" 
              (ngModelChange)="modelChange.next($event)" 
              required>
</mat-form-field>

parent:

<form #f="ngForm">
    <app-input [name]="'name for password'" 
               [name]="'name for password confirm'"
               [ngModel]="name"
               ngDefaultControl>
     </app-input>
</form>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to assess Python code within a document's context using JavaScript in JupyterLab?

When using Jupyter Notebooks, I can create a cell with the following JavaScript code: %%javascript IPython.notebook.kernel.execute('x = 42') After executing this code, in another cell containing Python code, the variable x will be bound to 42 a ...

Lack of intellisense support for .ts files in Visual Studio Code

Currently, I am using Visual Studio Code 1.17.2 on Arch Linux to kickstart my work with Node.js/Angular4. To avoid confusion caused by loosely typed code, I have decided to switch to TypeScript for my NodeJS server as well. This is why my main file is name ...

To handle the input field efficiently in Angular, consider utilizing two <input type="radio"> elements

I am facing a challenge in my Angular 5 project where I have two radio buttons and need to dynamically update the value of formControlName and placeholder for an input field based on the selected radio button. How can I tackle this issue? <div clas ...

Generating observables from form submission event

Note: I am completely new to Angular and RXJS. Currently, I am working on a simple form where I want to create an observable. The goal is to listen for submit events and update a value within the component. However, I keep encountering an error message sa ...

Guide on closing a Bootstrap modal by clicking within the UI Grid in Angular

I have an Angular app written in TypeScript where I am utilizing the ui grid to present data within a bootstrap modal. My goal is to have the modal close when any of the columns in a grid row are clicked. Currently, I am not relying on $modal or $modalIn ...

What is the process for implementing a unique Angular theme across all components?

I created a unique Angular theme called 'my-theme.scss' and added it to the angular.json file. While it works with most Angular Elements, I am facing issues getting it to apply to certain HTML Elements inside Angular Components. For example: < ...

`Troubleshooting problem with debugging mocha tests in a TypeScript environment`

I'm currently facing an issue while trying to debug a mocha test. Despite my efforts in searching on Google and Stack Overflow, I have not been able to find a solution. The error message is as follows: TSError: ⨯ Unable to compile TypeScript: sour ...

Navigating to sub-routing module without utilizing lazy loading

I prefer to use multiple routing modules to maintain a clean and readable application structure. Currently, I have implemented lazy loading for the SubComponent, but I am exploring alternatives to avoid this. Below is the functioning code in use: The foll ...

Collapse a previously used item when a new item is opened within Angular

I've managed to create a tree structure for a sideBar Menu using this code, and it's working well. However, what I'm trying to achieve is that when a menu with submenus is expanded and the user clicks on another parent menu, the expanded sub ...

Dynamic rendering of independent routes is achieved by nesting a router-outlet within another router-outlet

I am working on an angular 2 project with multiple modules. To load each module, I am using the lazy loading technique in this way: { path: 'home', loadChildren: './dashboard/dashboard.module#DashboardModule' }, Currently, I am facing ...

The specified property ID is not found in the User type

I recently started using TypeScript and decided to practice by implementing user authentication with Passport.js in a small application. Challenge The issue I'm facing is related to instructing Passport.js to store the id property of the user in the ...

The issue of Eslint flagging a no-unused-vars error when actually using an interface in a

Currently, I'm working with Vue along with Vue CLI and Typescript. I have imported an interface from a Vuex file and utilized it for type annotation in mapState. However, I am encountering an error flagged by eslint. 'State' is defined ...

Executing an asynchronous function within an Angular 7 interceptor is crucial

I've been working on creating an interceptor to handle a situation where a function needs to be called to refresh the session upon receiving a 401 error response. Here's what I have so far but I'm facing build issues and struggling to figure ...

How do decorators within Angular 2 impact components?

Can you help me understand the purpose of decorators in angular2? How do they allow for annotating and modifying classes and properties during design time? It seems similar to using annotations, could you clarify this concept for me please? Thank you in ...

Testing Angular combineLatest with Jest

I'm encountering a challenge in an assessment involving a complex Statement related to combineLatest. Here is the snippet of code: component: export class ErinnerungenErinnerungenComponent implements OnInit, OnDestroy { ... erinnerungen: Erinne ...

Set the GridToolbarQuickFilter text box to have an outlined style in Material UI v5

How can I customize the appearance of the GridToolbarQuickFilter textbox, such as outlining it? Ideally, I would like to accomplish this through theme.tsx, but I am open to any suggestions. https://i.stack.imgur.com/H1Ojj.png I have experimented with var ...

Ways to troubleshoot issues with the ng bootstrap package

Having an issue debugging ng-bootstrap 4 in my Angular 7 project, I decided to follow the instructions provided on this link to clone ng-bootstrap and install dependencies using yarn. The process completed without any errors. However, when attempting to np ...

Unveiling the Navigation Strategies Embedded in Angular Components

Currently, I have a collection of Angular components all configured with routing to assign a unique URL to each. The goal is to sequentially navigate from one component to the next based on user input. Some components may be visited multiple times at vario ...

Angular is not able to access the value of a promise in a different function after it has been retrieved

I have a form with default values that should be added to the form fields when it appears. There are two functions: #1 for fetching data from the backend and #2 for displaying the form: person$: any; ngOnInit() { this.getPersonData(123) this.buildPer ...

Retrieve data from REST call to populate Material dropdown menu

I am looking to dynamically populate a dropdown menu with data retrieved from a Rest API. I attempted the following code: <Select id="country-helper"> {array.map((element) => ( <MenuItem value={element.code}>{element.country}& ...