angular6

How to change element to input or dropdown in angular form?

非 Y 不嫁゛ 提交于 2019-12-01 12:00:29
问题 I am making angular 6 application, where i am using angular dynamic form and the values are coming from JSON.. Simple JSON : jsonData: any = [ { "elementType": "dropdown", "key": 'project', "label": 'Choose option to display', "options": [ { "key": 'inputbox', "value": 'Show Project Level as input box' }, { "key": 'dropdown', "value": 'Show Project Level as dropdown' } ], "order": 1 }, { "elementType": "textbox", "class": "col-12 col-md-4 col-sm-12", "key": "project_level", "label": "Project

How to change element to input or dropdown in angular form?

夙愿已清 提交于 2019-12-01 11:41:58
I am making angular 6 application, where i am using angular dynamic form and the values are coming from JSON.. Simple JSON : jsonData: any = [ { "elementType": "dropdown", "key": 'project', "label": 'Choose option to display', "options": [ { "key": 'inputbox', "value": 'Show Project Level as input box' }, { "key": 'dropdown', "value": 'Show Project Level as dropdown' } ], "order": 1 }, { "elementType": "textbox", "class": "col-12 col-md-4 col-sm-12", "key": "project_level", "label": "Project Level as input box", "type": "text", "value": "", "order": 2 }, { "elementType": "dropdown", "key":

Angular 6 cannot automatically select/bind dropdown list value from supplied object

帅比萌擦擦* 提交于 2019-12-01 10:20:45
问题 I get a country object from a service and bind it to a form that has a dropdown list of countries. The country doesn't appear selected after retrieving it from the service but all the other data is shown OK including a string gender field which is bound to a dropdown list. I can manually select the country from the list though. How can I automatically show the country as selected? personal-details.component.html <form [formGroup]="form" (submit)="doSave(form.values)"> <mat-card class="main

Pug support for Angular 2 / Angular 4 / Angular 6 / Angular cli / Angular cli 6 (without custom WebPack config)

感情迁移 提交于 2019-12-01 09:55:49
问题 How to install correctly PUG / JADE to Angular 2 or above So that while working and AOT and JiT Worked Unit and Integration Tests and do not suffer much when creating each new component 回答1: I saw many solutions, some of them: in each component was added something like "require!pug-loader()some.component.pug" Get away from using angular-cli and create magic around webpack Use other servers (who know how to work with the Pug / Jade) Before running the build, convert all the pug files to html I

Appending HTML snippet to the view in Angular 6

若如初见. 提交于 2019-12-01 09:38:49
I am getting a piece of html code from a http request to an external system , and I should show this on my view in my angular app to be percise this is the html snippet that I have to show (it will be a bit different by every request and response ) <div id='paysonContainer' url='https://test-www.payson.se/embedded/checkout?id=af1ebee5-40bd-410a-90d1-a94401553414'> </div> <script type='text/javascript' src='https://test-www.payson.se/embedded/Content/payson.js?v2'> </script> I used different solution suggestions like innerHtml , but non of them is working for me (maybe because I have some

how to throw observable error in angular http interceptor

拜拜、爱过 提交于 2019-12-01 07:03:14
I tried to throw an observable error in the interceptor and then handles this error. but I can't. When success is false, I can also receive successful subscribe. I tried to return a value again in next.handle(restReq) . But I failed and did not subscribe to anything restApi return like this { "success": false, "data": { "name": "Bad Request", "message": "123", "code": 0, "status": 400, "type": "yii\\web\\BadRequestHttpException" } } auth.service.ts import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs/internal/Observable

how to throw observable error in angular http interceptor

ε祈祈猫儿з 提交于 2019-12-01 03:46:56
问题 I tried to throw an observable error in the interceptor and then handles this error. but I can't. When success is false, I can also receive successful subscribe. I tried to return a value again in next.handle(restReq) . But I failed and did not subscribe to anything restApi return like this { "success": false, "data": { "name": "Bad Request", "message": "123", "code": 0, "status": 400, "type": "yii\\web\\BadRequestHttpException" } } auth.service.ts import { Injectable } from '@angular/core';

Angular 6 custom lib No provider for ComponentFactoryResolver

风流意气都作罢 提交于 2019-12-01 03:36:50
问题 I rewriting library from NG4 -> NG6 (using angular-cli 6). This lib change dynamicli angular components so I using ComponentFactoryResolver and here I got stuck. When I add ComponentFactoryResolver to constructor: constructor( private componentFactoryResolver: ComponentFactoryResolver ) {} and build lib (with success) in target app (I add my lib in package.json from local file) I have this error: StaticInjectorError(AppModule)[MyLibComponent-> ComponentFactoryResolver]: StaticInjectorError

Pass image from FileReader to form input in Angular 6

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 21:45:24
I try to create an UI where there is a form with a couple of text fields, a input type="file" and a div that you can drop images to upload with the rest of the form. My goal / logic use the same div to either drop an image or click on it and open the folder explorer like the input type="file" behaves. Enabling clicking makes sense in small screens where it is practically impossible to "drag and drop". And since there is already a input type="file" in the form there is no reason to take the image from the div and append it to the form etc etc. I try to take the image that is dropped in the div

Angular 6+ :ProvidedIn a non root module is causing a circular dependency

和自甴很熟 提交于 2019-11-30 21:29:13
问题 I'm trying to provide a resolve service via the new providedIn attribute. This is a translations resolver which I use in a protected module: import { Injectable } from '@angular/core'; import { Observable , pipe } from 'rxjs'; import {map} from "rxjs/operators"; //This is causing: "WARNING in Circular dependency detected:" import {ProtectedModule} from "../../../protected/protected.module"; import { HttpHandlerService } from '../../http/http-handler.service'; @Injectable({ providedIn: