Skip to main content

All Questions

2 votes
3 answers
177 views

Angular: difference between using signal and simple class member for holding state [closed]

I am using signals in Angular 18 for small local states. I don't understand what the difference is with a normal class member. Let's take a simple toggle: Example 1 @Component({...}) export class ...
ncasteln's user avatar
  • 311
1 vote
3 answers
120 views

How to bind an Angular signal/model to a template-driven <input> with an object as a value?

I'm trying to implement two-way binding in Angular18 by binding a property of an object within a signal (model) to ngModel. Specifically, I want to use a model signal as the source and ensure that ...
repi's user avatar
  • 23
1 vote
2 answers
63 views

In Angular 17+, how to pass signal<number | undefined> to a child component input signal<number>?

Say I have two parent & child components respectively: Parent Component: @Component({ selector: 'app-parent', template: `<app-child [id]="id()"></app-child>`, // this gives ...
Lakhveer's user avatar
0 votes
0 answers
135 views

Compute signal throwing error about derived signal is not a function

I am using Angular version 18.1.0 in a hybrid app mode environment (AngularJS + Angular 18) I have the following code that take in input signal and compute a signal dependent on the input signal. My ...
Dusty's user avatar
  • 1
1 vote
2 answers
101 views

Angular AuthGuard Not Blocking Access When Directly Navigating to blocked Routes

I'm working on an Angular application where I want to prevent authenticated users from accessing the login and signup pages. I have implemented an AuthGuard to handle this. The guard works as expected ...
Anas B's user avatar
  • 11
1 vote
1 answer
266 views

Serialising a model with signals in Angular 18

I'm trying to serialise a model object to local storage (or IndexedDB), however it contains signals. // An example of the model I'm dealing with export class ExampleModel { canSerialise = "&...
Jarno's user avatar
  • 113
1 vote
2 answers
139 views

Union types don't work in Angular ModelSignal<T> generic type

In Angular 18.1 I have the following code: public unit = model('px'); And it works correctly, indeed if I inspect the type I get: ModelSignal<string> I want to provide a better type definition ...
Christian Vincenzo Traina's user avatar
0 votes
1 answer
2k views

How to emit a click event with Angular 18 output api

I have a button component that receives some inputs and when is clicked I want to emit the fact that it's been clicked using the new output api. This is button.component.html <button (click)="...
SebastianoFazzino's user avatar