angular-components

Angular Form validation on child components

送分小仙女□ 提交于 2021-02-06 23:37:40
问题 I've written a dynamic form in which there is a main part and sub parts based on a type that's selected in the main part (widget.type). Showing and hiding the sub parts is done with an ngSwitch. HTML of the form looks like this: <form class="widget-form cc-form" (ngSubmit)="saveChanges()" novalidate> <div class="forms-group"> <label for="title" i18n="@@title">Titel</label> <input class="form-control" id="title" name="title" type="text" [(ngModel)]="widget.title" required /> </div> <div class=

Keep getting Uncaught (in promise): Error: Template parse errors: 'component' is not a known element:

那年仲夏 提交于 2021-01-29 15:24:07
问题 Here are some code fragments. Component: import { Component } from '@angular/core'; @Component({ selector: 'app-generalstatistics', templateUrl: './generalstatistics.component.html', styleUrls: ['./generalstatistics.component.css'] }) export class Generalstatistics { public data: Array<Object>; constructor() { } } app.module.ts: import { Generalstatistics } from './views/generalstatistics/generalstatistics.component'; declarations: [ .... Generalstatistics ], Implementation in DashboardModule

Is it possible to create an angular material mat-table component with extra directives but still keep columns dynamic?

穿精又带淫゛_ 提交于 2021-01-07 06:22:38
问题 Is there a way to extend a mat-table that automatically includes the matSort directive (and other custom directives that interact with the columns, like filter) and still have the content inside hold the mat-sort-header directives? <mat-table [matSortActive]="sortActive" [matSortDirection]="sortDirection" matSort> <ng-content></ng-content> </mat-table> Here is an example: https://stackblitz.com/edit/angular-bxsavu. I've tried creating a component on its own that just puts <ng-content> inside

Is it possible to create an angular material mat-table component with extra directives but still keep columns dynamic?

跟風遠走 提交于 2021-01-07 06:21:18
问题 Is there a way to extend a mat-table that automatically includes the matSort directive (and other custom directives that interact with the columns, like filter) and still have the content inside hold the mat-sort-header directives? <mat-table [matSortActive]="sortActive" [matSortDirection]="sortDirection" matSort> <ng-content></ng-content> </mat-table> Here is an example: https://stackblitz.com/edit/angular-bxsavu. I've tried creating a component on its own that just puts <ng-content> inside

How to instantiate Angular components with parameters?

廉价感情. 提交于 2021-01-03 07:02:21
问题 I've been trying to instantiate components by passing parameters like nameFilter = new FilterComponent("Name"); but I'm getting this error: NullInjectorError: No provider for String! I believe dependency injection causes this as I don't get any errors if I don't inject anything to component. So what exactly causes this and how can I fix it? Here's the component code import { Component, OnInit, Inject } from '@angular/core'; @Component({ selector: 'app-filter', templateUrl: './filter.component

How to instantiate Angular components with parameters?

孤人 提交于 2021-01-03 07:01:17
问题 I've been trying to instantiate components by passing parameters like nameFilter = new FilterComponent("Name"); but I'm getting this error: NullInjectorError: No provider for String! I believe dependency injection causes this as I don't get any errors if I don't inject anything to component. So what exactly causes this and how can I fix it? Here's the component code import { Component, OnInit, Inject } from '@angular/core'; @Component({ selector: 'app-filter', templateUrl: './filter.component

How to instantiate Angular components with parameters?

纵然是瞬间 提交于 2021-01-03 06:59:52
问题 I've been trying to instantiate components by passing parameters like nameFilter = new FilterComponent("Name"); but I'm getting this error: NullInjectorError: No provider for String! I believe dependency injection causes this as I don't get any errors if I don't inject anything to component. So what exactly causes this and how can I fix it? Here's the component code import { Component, OnInit, Inject } from '@angular/core'; @Component({ selector: 'app-filter', templateUrl: './filter.component

When to use Angular Directives, Components & Modules

天大地大妈咪最大 提交于 2020-11-28 19:47:50
问题 I've been reading the documentation but still seem to be confused on when you should use a directive or a component... Also, when is it best to abstract components and place them into modules?? 回答1: In fact, a component is also a type of directive according to the angular docs. There are three kinds of directives in Angular: 1. Components—directives with a template. 2. Structural directives—change the DOM layout by adding and removing DOM elements. 3. Attribute directives—change the