angular

Cannot set initial form values into FormArray

南笙酒味 提交于 2021-02-19 23:55:18
问题 I have a reactive form that on cancel has to set again the initial form values into the formGroup. import { Map } from "immutable"; @Input() data: any; public ngOnInit() { if (this.data && this.data.controls) { this.group = this.fb.group({ isActive: [this.data.isActive], items: this.fb.array(this.buildFormArray(this.data.controlPerformers)), }); // Deep copy of the formGroup with ImmutableJs this.originalFormData = Map(this.group).toJS(); } } public buildFormArray(controllers:

Cannot set initial form values into FormArray

感情迁移 提交于 2021-02-19 23:54:27
问题 I have a reactive form that on cancel has to set again the initial form values into the formGroup. import { Map } from "immutable"; @Input() data: any; public ngOnInit() { if (this.data && this.data.controls) { this.group = this.fb.group({ isActive: [this.data.isActive], items: this.fb.array(this.buildFormArray(this.data.controlPerformers)), }); // Deep copy of the formGroup with ImmutableJs this.originalFormData = Map(this.group).toJS(); } } public buildFormArray(controllers:

Cannot set initial form values into FormArray

半城伤御伤魂 提交于 2021-02-19 23:50:31
问题 I have a reactive form that on cancel has to set again the initial form values into the formGroup. import { Map } from "immutable"; @Input() data: any; public ngOnInit() { if (this.data && this.data.controls) { this.group = this.fb.group({ isActive: [this.data.isActive], items: this.fb.array(this.buildFormArray(this.data.controlPerformers)), }); // Deep copy of the formGroup with ImmutableJs this.originalFormData = Map(this.group).toJS(); } } public buildFormArray(controllers:

document setAttribute ngModel Angular

有些话、适合烂在心里 提交于 2021-02-19 19:44:12
问题 I am trying create an input element from typescript to html in angular 4. But when I try put [(ngModel)] not works. How I do that method ? Someone know how ? createElement() { this.input = document.createElement('input'); this.input.setAttribute('matInput', ''); this.input.setAttribute('placeholder', 'Tema'); this.input.setAttribute('[(ngModel)]', 'module.theme'); this.input.setAttribute('name', 'theme'); return (<HTMLDivElement>(document.getElementById('ejemplo').appendChild(this.input))); }

ng-select reusable templates

廉价感情. 提交于 2021-02-19 09:28:36
问题 I'm using ng-select (https://github.com/ng-select/ng-select) library to work with multiselect drop down lists. It works great but now I need to reuse my ng-templates and I'm kind of lost. I started working on Angular 10 a few weeks ago and Googled enough to realize I need some help. My ng-template looks like this: <ng-template ng-header-tmp let-item$="item$"> <div> <input type="text" appAutofocus class="form-control input-sm ng-select-search-box" placeholder="Filter" (input)="ngSelectControl

ng-select reusable templates

萝らか妹 提交于 2021-02-19 09:27:37
问题 I'm using ng-select (https://github.com/ng-select/ng-select) library to work with multiselect drop down lists. It works great but now I need to reuse my ng-templates and I'm kind of lost. I started working on Angular 10 a few weeks ago and Googled enough to realize I need some help. My ng-template looks like this: <ng-template ng-header-tmp let-item$="item$"> <div> <input type="text" appAutofocus class="form-control input-sm ng-select-search-box" placeholder="Filter" (input)="ngSelectControl

Angular / svg - pass data into svg

旧街凉风 提交于 2021-02-19 08:51:20
问题 I have a stackblitz here - https://stackblitz.com/edit/angular-vkwets?file=src%2Fapp%2Fdonuts.template.html I have an Angular component that creates an svg donut chart for each data point of an array passed to the component. I can access the data passed into the component but is it possible to use this in the svg. I would like to update the 'stroke-dasharray' in the svg using the data passed to the component. something like stroke-dasharray=donut.percent 100-donut.perecent <div> <ul> <li

Angular / svg - pass data into svg

徘徊边缘 提交于 2021-02-19 08:51:08
问题 I have a stackblitz here - https://stackblitz.com/edit/angular-vkwets?file=src%2Fapp%2Fdonuts.template.html I have an Angular component that creates an svg donut chart for each data point of an array passed to the component. I can access the data passed into the component but is it possible to use this in the svg. I would like to update the 'stroke-dasharray' in the svg using the data passed to the component. something like stroke-dasharray=donut.percent 100-donut.perecent <div> <ul> <li

Converting an array in curly braces to a square bracketed array

五迷三道 提交于 2021-02-19 08:48:05
问题 I've inherited a database that stores an array of strings in the following format: {"First","Second","Third","Fourth"} This is output as an ordered list in the application. We're replacing the front-end mobile app at the moment (ionic / angular) and want to do an ngFor over this array. In the first iteration, we did a quick and dirty replace on the curly brackets and then split the string on "," but would like to use a better method. What is the best method for treating this type of string as

How to loop with *ngFor in array of objects?

≡放荡痞女 提交于 2021-02-19 08:42:30
问题 I'm learning Angular2, so please forgive me if I'm asking a stupid question. I am receiving an arrays of objects and it looks like this: obj.json data: [ { item: "banana" } ], [ { item: "apple" } ], [ { item: "lemon" } ] In my component file I have managed to scope it in a scope: this.fruits = data[0].item; The issue is I only manage to scope the first item, or the second item and so on, by the index. How can I scope them all and then show them in a HTML file with *ngFor ? 回答1: Your array isn