How to set value PrimeNG p-dropdown with a value read from the server?

I receive the value of myModel.field correctly from a server (for example myModel.field = "id2"), but it is not selected in the p-dropdown, what should I do? This is my options (the dropdown populates fine): options = [ { label: ‘Opt1’, value: ‘id1’ }, { label: ‘Opt2’, value: ‘id2’ }, { label: ‘Opt3’, value: ‘id3’ […]

By doinel
Published
Categorized as angular, primeng, primeng-dropdowns Tagged , ,

Angular doesn’t add ng-invalid when I add required on input element by Renderer2

I want to put the attribute "required" dinamically on an input text field using Renderer2. The attribute is added, but the field doesn’t turn to invalid when the field is empty. I tried different ways that I list above, but nothing works: this.renderer.setAttribute(elementRef.nativeElement, ‘required’, ‘true’); this.renderer.setAttribute(elementRef.nativeElement, ‘required’, ”); this.renderer.setAttribute(elementRef.nativeElement, ‘ng-reflect-required’, ‘true’); How can I do? […]

Filter() in Angular2

I have Product: {code: string, description: string} productsA: Product[] productsB: Product[] I want to get productsC: Product[] that contains all products of productsA that have ‘code’ other than productsB’s product codes Example: productsA = [{‘c1’, ‘des1’}, {‘c2’, ‘des2’}, {‘c3’, ‘des3’}] productsB = [{‘c1’, ‘des4’}] I want productsC = [{‘c2’, ‘des2’}, {‘c3’, ‘des3’}] How can I […]

By doinel
Published
Categorized as angular, filter, filtering Tagged , ,

Set focus on p-inputNumber

I open a p-dialog with a p-inputNumber inside, but I don’t manage to set focus on it. I tried to put autofocus, as you see, but it doesn’t work. The focus remains on the button I pressed to open the dialog. How can I do? Thanks. <p-dialog header="Title" [(visible)]="displayModal" [modal]="true" [style]="{width: ’40vw’}" [baseZIndex]="10000" [draggable]="false" [resizable]="false" […]

By doinel
Published
Categorized as angular, autofocus, focus, primeng, typescript 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
faq