How to add formControl programmatically in typescript?

Is it possible to add form control to a (in component.ts) created component instance? I dynamically create a component with the componentFactoryResolver and render it in a ng-template. Since i cannot add the directive formControlName to a ng-template i need to add this to the instance of the new created component in the component.ts. How […]

By Patrick
Categorized as angular, html, typescript Tagged , ,

How to add a directive (formControlName) to an component instance (in typescript)?

I try to dynamically create input forms with form support. It is working just fine, since i can add the directive "formControlName" directly on the html-element. But now i dont know how i can set the directive to the instance of a dynamically created component which takes place instead of a ng-template. the directive myCustomComponentDirective […]

By Patrick
Categorized as angular, controlvalueaccessor, typescript Tagged , ,

Angular + Django Backend. How to Log in base on user types in Django

Im facing a problem on how to integrate user permission like if the is_superuser is False, then log in to Author component and if Superuser is True, log in to Admin Component in Angular. I hope someone can help What I want, 1) If the is_superuser is True in django, then log in to a […]

By Patrick
Categorized as angular, django Tagged ,

HttpClient POST with HttpParams

I am attempting to POST to an endpoint that requires arguments are passed as query string parameters and not via the POST body. const params = new HttpParams() .set(‘param1’, ‘1’) .set(‘param2’, ‘2’); const url = environment.apiUrl + ‘Service/Endpoint’; return this .httpClient .post<ServiceResponse>(url, { params }) .pipe(map(res => res.httpStatusCodeSuccess)); This is returning a 404 as the […]

RxJS (Interval) Observable wait for last observable to complete

I want an interval observable which waits for the last execution. This are my tries. Simple thing which not wait. interval(1000) .subscribe(async x => { await new Promise(resolve => setTimeout(resolve, Math.floor(Math.random() * 10000) + 1000)); console.log(‘Got counter’, x); }); Results in: 4, 1, 2, 6, 9, 7, 6, 3, … Next try but a bit […]

PrimeNG Dropdown binding to disabled property not working

I have a PrimeNG p-dropdown control with its disabled property bound to a boolean property. Essentially it looks like this: <p-dropdown [disabled]="disableGroupsDropdown"></p-dropdown> This boolean defaults to true, and the dropdown is properly disabled. I have other code that can modify this boolean property. When I execute this code, the state of the dropdown doesn’t change. […]

By Patrick
Categorized as angular, primeng, primeng-dropdowns Tagged , ,

How to apply a class to ng-container outlet in Angular2+?

How can I apply the class "exampleClass" to the content of the container? class in custom.component.ts: exampleClass { backgroundColor: "red"; } HTML in Component of the custom.component.html: <ng-container [ngTemplateOutlet]="customDirective.templateRef" [ngTemplateOutletContext]="{ $implicit: item, index: i}"> </ng-container> the HTML where i use it somewhere.component.html: <custom-component> <ng-template customDirective> <div> the div i want to apply the class // […]

By Patrick
Categorized as angular, css, javascript Tagged , ,

Observable repeatWhen & retryWhen other observable is true (network is connected)

Example code: const networkConnected = new BehaviorSubject<boolean>(false); setTimeout(, 10000); webSocket(‘ws://localhost:4949’) .pipe( retryWhen(errors => errors.pipe(delay(10000), filter(() => networkConnected.value === true))), repeatWhen(completed => completed.pipe(delay(10000), filter(() => networkConnected.value === true))), tap(a => console.log(‘Connecting…’)) ).subscribe( message=>, error => console.error(error), () => console.warn(‘Completed’), ); I searched for one hour and wasnt able to find one other person who want […]

How to get angularStrict template checking highlighting in html

I am currently trying out the strictTemplate flag in angular. Now the compiler picks up a lot of things which is great but i am wondering why vs code doesn’t show these errors in the html. Tslint and also the angular language server are installed. Example: I have an @Input(): ((test: string) => Promise<string>) and […]

Correct usage of PouchDB in Anguar2+?

I tried to store objects in a pouchdb at the client. creating the DB and fetch all docs is working well. but when i try to query the DB by db.find() it takes several minutes to get it – also the browser lags and the CPU and RAM increases a lot. i know there is […]

By Patrick
Categorized as angular, pouchdb Tagged ,

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us