Questions tagged typescript

Explore the latest questions and answers asked by our top developers.

How to filter array of objects and assign it in new variable list in typescript?

Need to retrieve records of male objects from the list. list=[ { id: 1, name: "Sam", sex: "M"}, { id: 2, name: "Jane", sex: "F"}, { id: 3, name: "Mark", sex: "M"}, { id: 4, name: "Mary, sex: "F"}, { id: 5, name: "Olivia", sex: "F"}, { id: 6, name: "Bob", sex: "M"} ] var […]

By Shahrooz M
Published
Categorized as angular, list, typescript Tagged , ,

Why in my Angular application using typescript, is not changing my variable inside a function in this situation?

I’m having a strange problem. In my component CategoryComponent i have a variable in escope that is: @Input() category: CategoryModel; When i make a simple post with a service and return a data i change this variable to change so i make a function that do this: if (category.uploading) { this.checkMedia(this.category, this.module); } Inside my […]

By wavrik
Published
Categorized as angular, typescript Tagged ,

How to toggle Admin LTE 3 sidebar manually in angular12?

I have implemented Admin LTE 3 theme in my project and implemented. layout.html <div class="wrapper w-100"> <!– Navbar –> <app-header></app-header> <!– /.navbar –> <!– Main Sidebar Container –> <app-sidebar></app-sidebar> <!– Content Wrapper. Contains page content –> <div class="content-wrapper"> <router-outlet></router-outlet> </div> <!– /.content-wrapper –> <!– Control Sidebar –> <app-control-sidebar></app-control-sidebar> <!– /.control-sidebar –> <!– Main Footer –> […]

By Fahad Subzwari
Published
Categorized as angular, typescript Tagged ,

After populating the object I want to use the fields to get data for a other object

I have populated my object Contract when using the debugger I can see it has populated the object. But later when I want to use the objects fields but it is undefined. I do not understand why this is the case. Here is the line in question where contract is undefined. console.log("test id contract client" […]

By Junior Cortenbach
Published
Categorized as angular, typescript Tagged ,

document.ActiveElement always returns body Angular

So what was happening is like the title says. On (focusout) when I called a method that checks if an element is an document.activeElement (focused), I was always getting the body as a result. Only if I click on another window/inspector tools I was getting a correct result when doing a console.log which was in […]

By ToneyPK
Published
Categorized as angular, javascript, onfocus, typescript Tagged , , ,

Angular DI classType: Type<MyClass> is not a constructor

So I try to use angular dependency injection in ngOnInit instead of constructor. I found some examples of this using a factory provider, but things does not quite work… I get a reference to a let myClassType: Type<MyClass> = …. object that I can instantiate myself using let myClassInstance = new myClassType(http) but when I […]

By Payerl
Published
Categorized as angular, dependency-injection, typescript Tagged , ,

Argument of type ‘"content"’ is not assignable to parameter of type ‘TemplateRef<any>’.ts(2345)

I want to open a modal when I click on a button. But I cannot pass the template reference to my modal. In my nav.component.html <button *ngIf="!loggedIn" class="btn btn-outline-success ms-3" (click)="open()"> Sign Up </button> In nav.component.ts open() { this.modalShared.openModal(‘content’); } In my modal.component.ts import { Component, OnInit, TemplateRef, Input, Injectable } from ‘@angular/core’; import { […]

By Ridwan
Published
Categorized as angular, html, typescript Tagged , ,

Multiple 401 Angular Token Interceptor

I have created a Token Interceptor in Angular which I use to refresh my JWT token. Unfortunately, I don’t know why, several calls fail (error 401) and when the interceptor retrieves the new token, only the last one that failed is redone. This means that it miss some calls and my UI is not filling […]

The correct way to implement login with router modules

I’m trying to create a basic page with login. If user is not logged in then can only access to Login and Register page (I did it with Guards) When the user is logged in then can only access to de MainPage ‘/’. I don’t know how do this correctly. This is my code but […]

How to overwrite / match extended CurrencyPipe method type in Angular

I am trying to reuse existing currency pipe from Angular common. Goal is to have .00 truncated when the value is round. For this I’ve wrote this piece of code: /** Transform currency string and round it. */ @Pipe({name: ‘customCurrency’}) export class CustomCurrencyPipe extends CurrencyPipe implements PipeTransform { transform(value: number|string|null|undefined): string|null { if (!isValue(value)) return […]

By Luke
Published
Categorized as angular, angular2-pipe, oop, typescript Tagged , , ,
1 2 3 1,366

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
faq