Skip to content

@ngrx/signals: No provider for SignalStore #4150

Closed Answered by pavankjadda
pavankjadda asked this question in Q&A
Discussion options

You must be logged in to vote

This is for the people facing similar issue and looking for 101 of the Signal Store. Add EmployeeStore to providers in the component and it will solve the issue.

@Component({
	selector: 'app-employee-component',
	standalone: true,
	imports: [],
	providers: [EmployeeStore],
	templateUrl: './employee.component.html',
})
export class EmployeeComponent implements OnInit {
employeeStore=inject(EmployeeStore);
}

Global Store:

Specifying { providedIn: 'root' }will define it in root context and will create global EmployeeStore. This can be used in any component without adding in providers

export const EmployeeStore = signalStore({ providedIn: 'root' }, withState(initialState));

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@KylerJohnsonDev
Comment options

@pavankjadda
Comment options

Answer selected by pavankjadda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants