Smart UI Components & Libraries – Grid, Scheduler, Gantt, Kanban for Angular, React, Next.js, Vue, Blazor, JavaScript › Forums › Editor & Inputs › How do I use Angular resolvers to preload data for Input?
- This topic has 1 reply, 2 voices, and was last updated 2 months ago by Markov. 
- 
		AuthorPosts
- 
		
			
				
August 26, 2025 at 7:23 am #112882linda05 ParticipantAre there examples of using Smart.DateInput with state management (like Redux, VUEx, etc.)? How to sync global and local state? August 26, 2025 at 8:40 am #112884Markov KeymasterHi, A resolver is a service that implements Resolve<T> and pre-fetches data before the route activates. 
 The resolved data is then available via ActivatedRoute in your component.This is perfect for @Input() bindings, because you can ensure the input has data immediately when the component is rendered. Create a Resolver // date.resolver.ts 
 import { Injectable } from ‘@angular/core’;
 import { Resolve } from ‘@angular/router’;
 import { Observable, of } from ‘rxjs’;
 import { DateService } from ‘./date.service’;@Injectable({ providedIn: ‘root’ }) 
 export class DateResolver implements Resolve<Date> {
 constructor(private dateService: DateService) {}resolve(): Observable<Date> { 
 // Simulate API call or fetch default date
 return this.dateService.getDefaultDate();
 }
 }Attach Resolver to Route // app-routing.module.ts 
 import { NgModule } from ‘@angular/core’;
 import { RouterModule, Routes } from ‘@angular/router’;
 import { DateInputPageComponent } from ‘./date-input-page/date-input-page.component’;
 import { DateResolver } from ‘./date.resolver’;const routes: Routes = [ 
 {
 path: ‘date-input’,
 component: DateInputPageComponent,
 resolve: { defaultDate: DateResolver } // key = ‘defaultDate’
 }
 ];@NgModule({ 
 imports: [RouterModule.forRoot(routes)],
 exports: [RouterModule]
 })
 export class AppRoutingModule {}// date-input-page.component.ts 
 import { Component, OnInit } from ‘@angular/core’;
 import { ActivatedRoute } from ‘@angular/router’;@Component({ 
 selector: ‘app-date-input-page’,
 template: `
 <smart-date-input [value]=”preloadedDate”></smart-date-input>
 `
 })
 export class DateInputPageComponent implements OnInit {
 preloadedDate!: Date;constructor(private route: ActivatedRoute) {} ngOnInit(): void { 
 this.preloadedDate = this.route.snapshot.data[‘defaultDate’];
 }
 }In general: [value] binds the preloaded date to the Smart.DateInput. 
 Resolver ensures the data is ready before component initialization, so the date input is populated immediately.Hope this helps. Best regards, 
 MarkovSmart UI Team 
 https://www.htmlelements.com/
- 
		AuthorPosts
- You must be logged in to reply to this topic.