peterbsmyth / ngx-breadcrumbs

Angular 4+ routing breadcrumbs
MIT License
59 stars 43 forks source link

Using Resolver in routes #2

Open Parilar opened 6 years ago

Parilar commented 6 years ago

Hello, i've used this tutorial to get familar with AngularJs. Breadcrumbs are working, except the part with the resolver. How does a Resolver has to look for this lib? Already tried to use the Resolver from the repo but i still got the message that person is undefined.

I would be grateful for help

My Resolver (for testing)

    import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
    import { Injectable } from '@angular/core';
    import { IRecipe } from "../_class/person";

    @Injectable()
    export class PersonResolver implements Resolve<IRecipe> {

    constructor(private service: PersonService) { }

    public resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<IPerson> {

        const id = route.params.id;

        if (id) {
            return Promise.resolve({
                id: 900,
                title: "666666"
            });
        } else {
            return Promise.resolve({
                id: 0,
                title: ""
            });
        }
    }
    }
dimamarksman commented 6 years ago

I'm not sure but probably you should inherit from McBreadcrumbsResolver link