New answers tagged angular
0
votes
Typescript reach defined type from variable in Angular
You have to set keyof TypeMap for the variables, then it will access the index type.
interface Bus {
id: number;
test?: string;
}
interface Area{
id: number;
load?: string;
}
type TypeMap= {...
0
votes
Error in console: ng.probe is not a function
Try these in console instead:
$state/$scope/$context: Element debug info
$apply/$applyChanges(): Trigger change detection cycle
0
votes
Angular and contenteditable
I use a MutationObserver to watch text change on the element.
It works pretty well so far:
import { isPlatformBrowser } from '@angular/common';
import {
Directive,
ElementRef,
OnDestroy,
...
0
votes
Swiper 11 and Angular 17 SSR ERROR TypeError: this.el.nativeElement.initialize is not a function
Not sure if this is still an issue but I got this error to fix on my end by simply importing 'register' and initializing it before anything else in my main.ts file.
import { register } from 'swiper/...
0
votes
How to add version to index.html during ng build?
Create a Node.js script to read the version number and inject it into index.html.
const fs = require('fs');
const path = require('path');
const packageJson = require('./package.json');
// Read ...
0
votes
Angular 16 RxJs Issue Updating Total on Header Component
You need a service to share data between components like this:
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { Cartitems } from './cartitems.interface';...
0
votes
Can I Safely Remove zone.js Dependency in Angular 18 with Experimental Zoneless Change Detection?
Enabling zoneless is exactly this : build and run angular without the zone.js dependency.
The NgZone implementation will not rely on zone.js but on a dummy implementation called NoopNgZone.
0
votes
Error on GET with authorization-header - only in Browser (CF-RestApi & Angular)
you need a proxy for your development environment.
Check this out:
https://v17.angular.io/guide/build#proxying-to-a-backend-server
0
votes
Angular 13 while deploying in Jenkins, the platform team is saying that AEM publishers are crashing
AEM in this case is Adobe Experience Manager. But the solution sounds simple enough, throttle the logs - either in Angular, if Angular is directly writing logs to the file system, set it to write out ...
1
vote
Accepted
How to extract colors from a palette in Material 3
You can use mat.get-theme-color for this.
Full Detailed Docs for get-theme-color
background-color: mat.get-theme-color($theme, primary, 50) !important;
We should also be aware of the number ranges ...
1
vote
How to use the retry from Rxjs to my await function?
You can use this article code which seems to be exactly what you need. It has support for number of retries and custom error message.
import './style.css';
let i = 0;
const promiseFn = () => {
...
0
votes
Using async/await with a service call
When you think of observables, consider it normal to place the additional actions inside the subscribe. The code in the subscribe is asynchronous (waits for the API to complete) the code below the ...
1
vote
Replacing a nested subscribe when getting multiple details from one initial call for ids
My approach involves using switchMap and forkJoin. First we use the observable to get all the ID fields, then we can use switchMap to switch from outer observable to inner observable. I then convert ...
0
votes
Angular can not upload file via formData
I couldn't find solution so I decided to use axios instead. It works well
const formData = new FormData();
formData.append('file', file);
const headers = {
'Content-Type': 'multipart/form-data'
};
...
0
votes
How to use animations in an angular standalone component
For Angular 18, you need to add provideAnimations() to the providers list of app.config.ts and app.config.server.ts.
is after doing that that it finally started work for me.
0
votes
angular/material 6 menu only opens in top left
I was missing the basic Angular material setup. Adding the following lines to my styles.scss fixed the problem:
@import '~@angular/material/theming';
@include mat-core();
Make sure to check out the ...
0
votes
Angular Material Autocomplete force selection
I didn't want to use setTimeout() because it seem very dirty, and you will always have a short, unwanted delay.
So i found a solution without setTimeout(), but utilizing (mousedown) on the mat-option.
...
0
votes
Accepted
error NG8002: Can't bind to 'ngSrc' since it isn't a known property of 'img'
I figured out what was the problem. I used non standalone component. So with standalone component it works well.
0
votes
Replacing a nested subscribe when getting multiple details from one initial call for ids
You can definitely use Promises for this. But you could also use RxJS for this well. It can be done like this:
loadWigitsDetailed() {
this.wigitGetterService.fetchWigitIds({ category: 'big' })
....
2
votes
Accepted
ng not found error when building Angular project using dockerfile
You shouldn't use the latest tag of the node image with Angular projects. Angular only supports the LTS version. In the stable channel some changes might be made which Angular first needs to adapt for....
0
votes
Using async/await with a service call
I see you are using "subscribe", which imply RxJS. You could use the lastValueFrom function to convert your observable to a promise.
import { lastValueFrom } from 'rxjs'
async ...
0
votes
no data in NYC .nyc_output/out.json = Angular18 + Cypress + Code Coverage
I got it working. The minimum reproducible repo has become a working repo with both Cypress e2e (npm run e2e) and component testing (npm run ct) code coverage. I hope this helps you. :)
https://...
0
votes
origin 'http://localhost:4200' has been blocked by CORS policy in Angular7
in your spring boot application,
1- add :
@CrossOrigin(origins = "http://localhost:4200")
to the Controller Class,
OR
2- add :
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:...
0
votes
Angular local library component rendering error (reading 'bindingStartIndex')
adding "@angular/*": ["./node_modules/@angular/*"] to the paths of tsconfig.json did the trick.
Not sure if I'd ever find it out on my own.
1
vote
Angular 18 SSR Vercel issue with 404
I made it work.....
api/index.js
export default import('../dist/project/server/server.mjs')
.then(module => module.app());
vercel.json
{
"version": 2,
"public": true,
&...
0
votes
Angular Input validate only on click. reset when user type or remove entire text
You have to use the parameter updateOn of formGroup to 'submit', by doing the form only evaluates the validation on click of submit button. Note that I am using a button of type submit and moved the ...
0
votes
Angular Input validate only on click. reset when user type or remove entire text
If you only have required validator this should work, otherwise it will be red until it's valid.
<form [formGroup]="userForm" #form="ngForm" novalidate>
<div class="...
1
vote
Angular Signals: How to trigger an effect based on a signal without using its value?
I couldn't find a better way other than to either use the toObservable() as mentioned by @JSONDerulo or to trigger the signal getter inside the effect().
However you could define a named effect ...
1
vote
Accepted
Angular Signals inside effect()
You can just use toObservable for this. To Convert to observable then use switchMap to switch to the API observable you need, this will react when the signal changes.
item_id = input<string>();...
0
votes
Angular directive css class selector is not working when class added by ngClass directive
You can use attribute selector to select the target of HTML element that contain the specific attribute. Attributes selectors are contained within []
@Directive({
selector: '.test',
standalone: ...
1
vote
Accepted
Firefox | HTMLVideoElement currentTime 0 after executing play()
It seems like you are currently relying on the Chrome specific implementation of the .play() function, where the currentTime is greater than 0 right after the function was called. But there is no ...
2
votes
Angular Signals: How to trigger an effect based on a signal without using its value?
You can use toObservable() to convert the signal to an Observable:
constructor() {
toObservable(this.authService.userAuthorized)
.pipe(takeUntilDestroyed())
.subscribe(() => this....
0
votes
Install peer dependencies in lib automatically on the client side
Packages, which the library itself depends on should be in dependencies and not in peerDependencies. This will also make sure that the packages are installed always.
According to the npm docs, peer ...
0
votes
Issue with primeng ngmodel binding after upgrading to 16.2.0.even though i select the date ,it is not getting selected
same issue i am facing my data not show input box for calender
<div class="field flex-wrap gap-3 p-fluid">
<label>
{{ label }}
@if(required){
<span ...
0
votes
The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used
Pls re-install asp.net by aspnet_regiis command.
2
votes
Rxjs concatMap that resolves to switchMap
Take this approach instead :
private cache = new BehaviorSubject<any>(undefined);
public cache$ = this.cache.asObservable().pipe(
filter(Boolean);
);
loadData() {
if (this.cache.value) ...
1
vote
Rxjs concatMap that resolves to switchMap
Looks too complicated, you can convert the promise to an observable using from and then use share to cache the value. There is no need for the behaviour subject.
test$ = new BehaviorSubject<any[] | ...
0
votes
How to resolve ngx-bootstrap Dependency Error
let me help you with logs. It says that it can't install [email protected] because it found that you already got installed @angular/[email protected], probably it's in your package.json.
Next it ...
0
votes
Ionic NFC cordova plugin_not_installed
Did you add the provider like that in app.module.ts ? 😉
@NgModule({
imports: [
BrowserModule,
...
],
declarations: [ AppComponent ],
providers: [ NFC ],
bootstrap: [ AppComponent ]
}...
0
votes
Angular: Data path "" must have required property 'buildTarget'
The best way is to revert the commit or discard changes, if you are using git.
Create a new ionic project with the same version as your project.
Then compare the architect.js with your file.
See ...
0
votes
Optimizing Angular HTTP Interceptor for Refresh Token
You need to use HttpBackend, where calls made through this are not intercepted by the interceptor, hence preventing the infinite loop.
From the docs:
A final HttpHandler which will dispatch the ...
0
votes
Optimizing Angular HTTP Interceptor for Refresh Token
You can prevent the interceptor from intercepting the refresh token request by using a flag or token in the HTTP headers to bypass interception. Ensure the interceptor skips handling requests marked ...
0
votes
CDK Drag and Drop - How to always add dragged item as last child in container during preview?
I just adjusted the code, to push the element to Infinity, this gets rid of this bug and guarantees the position at the last of the list.
If you want to push to the top of the list then -Infinity.
...
1
vote
Accepted
Component init inside ng bootstrap accordion even if closed
UPDATE:
The problem was that the accordion body content must be wrapped in an ng-template since this was not done, the content is getting rendered even when the accordion is not open.
The same method ...
1
vote
Accepted
Combines Angular Material table-expandable-rows and table-wrapped, and adds custom expand details but cannot show the custom detail content
When I changed ContentChild to
@ContentChild('temp', {
read: TemplateRef,
})
template: TemplateRef<any>;
It started working, so we need to be specific with the selector. Also promote ...
0
votes
How to Launch Notepad++ from Angular 18 Project on Button Click?
Generally speaking, you should be able to use exec from Node's child_process module. Read the documentation for detailed information.
I don't program Electron (or server JavaScript for that matter), ...
0
votes
How to write unit test case using Jamine to test form controls touched, untouched and dirty conditions
You have to mock the conditions so that the execution goes inside the if condition.
Also note, I am failing all two if conditions, except the last, this is to demo a simple method to cover chained ...
0
votes
Need BrowserAnimationsModule in Angular but gives error in Universal
You don't need to create a separate module,
Just replace:
// BrowserModule,
BrowserAnimationsModule,
You cannot use both together.
0
votes
Angular 10 error: Object is possibly 'undefined' when accessing the previous array element
If it is array, then easy, make the default value to [], like this:
@Input() books: Array<Book> = [];
What if value is an object, like Pagianation object something {x:xx, y: xx, records: [...]}...
0
votes
Primeng p-calendar same size as parent
An option to use utility classes from frameworks like PrimeFlex is using styleClass. This works even with other components from PrimeNG:
<p-calendar styleClass="w-full" />
Top 50 recent answers are included
Related Tags
angular × 305831typescript × 74088
javascript × 52834
html × 20395
angular-material × 15222
rxjs × 14009
css × 12292
ionic-framework × 12166
node.js × 9623
firebase × 6106
observable × 6060
angular-cli × 5951
ionic2 × 5766
angular6 × 5075
json × 4668
angular-reactive-forms × 4560
angular2-routing × 4339
npm × 4219
unit-testing × 4190
ionic3 × 4169
angular5 × 4139
primeng × 4086
jasmine × 3883
ngrx × 3872
angularjs × 3859