JonnyBGod / ngx-scrollspy

Angular ScrollSpy Service
MIT License
94 stars 21 forks source link

Cannot find name 'ScrollSpyModule'. #68

Closed kodiraj closed 7 years ago

kodiraj commented 8 years ago

i did as per the readme text .

when i try to start using npm,i get the below error

app/app.module.ts(19,5): error TS2304: Cannot find name 'ScrollSpyModule'.

JonnyBGod commented 8 years ago

I just updated readme.md with proper inputs for demos. My mistake sry.

kodiraj commented 8 years ago

Thanks .it solved the error.But new errors pop up.

You have working version of this.?

kodiraj commented 8 years ago

in my app.module.ts
import { ScrollSpyModule } from 'ng2-scrollspy';

@NgModule({ bootstrap: [App], declarations: [ App ], imports: [ // import Angular's modules BrowserModule, HttpModule, RouterModule, FormsModule, ReactiveFormsModule, ScrollSpyModule.forRoot(), NgaModule, PagesModule, routing ], providers: [ // expose our Services and Providers into Angular's dependency injection ENV_PROVIDERS, APP_PROVIDERS ] })

in my page.module.ts import { ScrollSpyElementDirective, ScrollSpyService } from 'ng2-scrollspy'; @NgModule({ imports: [CommonModule, NgaModule, routing], declarations: [Pages,ScrollSpyElementDirective] })

in my page.componenet.ts

import { ScrollSpyElementDirective, ScrollSpyService } from 'ng2-scrollspy';

export class Pages {

constructor(scrollSpyService: ScrollSpyService) { this.scrollSpyService = scrollSpyService; }

ngAfterViewInit() {
    this.scrollSpyService.getObservable('test').subscribe((e: any) => {
        console.log('ScrollSpy::test: ', e);
    });
}

}

when i run through npm

[default] /Users/kodiraj/Downloads/nextgenportal1/src/app/pages/pages.component.ts:38:14 Property 'scrollSpyService' does not exist on type 'Pages'. [default] /Users/kodiraj/Downloads/nextgenportal1/src/app/pages/pages.component.ts:42:14 Property 'scrollSpyService' does not exist on type 'Pages'. [default] Checking finished with 5 errors

it would really help ,if you have some demo of this feature

JonnyBGod commented 8 years ago

in you pages.component.ts you should declare the scrollSpyService variable. One way is:

export class Pages {
    constructor(private scrollSpyService: ScrollSpyService) {
    }

    ngAfterViewInit() {
        this.scrollSpyService.getObservable('test').subscribe((e: any) => {
            console.log('ScrollSpy::test: ', e);
        });
    }
}
kodiraj commented 8 years ago

hi,

Can you share some demo code if possible..

On Sep 21, 2016, at 7:43 PM, João Ribeiro notifications@github.com wrote:

I just updated readme.md with proper inputs for demos. My mistake sry.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JonnyBGod/ng2-scrollspy/issues/68#issuecomment-248624847, or mute the thread https://github.com/notifications/unsubscribe-auth/AKzpwzL7BSV0GhSEM1gMIlk5pvBUqU2Bks5qsTucgaJpZM4KCY4H.

kodiraj commented 8 years ago

hi,

i have nested components.Here how should i handle it?

On Sep 26, 2016, at 7:31 PM, João Ribeiro notifications@github.com wrote:

in you pages.component.ts you should declare the scrollSpyService variable. One way is:

export class Pages { constructor(private scrollSpyService: ScrollSpyService) { }

ngAfterViewInit() {
    this.scrollSpyService.getObservable('test').subscribe((e: any) => {
        console.log('ScrollSpy::test: ', e);
    });
}

} — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JonnyBGod/ng2-scrollspy/issues/68#issuecomment-249577841, or mute the thread https://github.com/notifications/unsubscribe-auth/AKzpw7-XsRV87QpSGKYpydqngynDUGccks5qt9BMgaJpZM4KCY4H.

kodiraj commented 8 years ago

scrollSpyElement=“kodiraj"

i declared the above tag in only one place.

ScrollSpy: duplicate id "kodiraj". Instance will be skipped!

But i get the error in the console.

On Sep 26, 2016, at 7:31 PM, João Ribeiro notifications@github.com wrote:

in you pages.component.ts you should declare the scrollSpyService variable. One way is:

export class Pages { constructor(private scrollSpyService: ScrollSpyService) { }

ngAfterViewInit() {
    this.scrollSpyService.getObservable('test').subscribe((e: any) => {
        console.log('ScrollSpy::test: ', e);
    });
}

} — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JonnyBGod/ng2-scrollspy/issues/68#issuecomment-249577841, or mute the thread https://github.com/notifications/unsubscribe-auth/AKzpw7-XsRV87QpSGKYpydqngynDUGccks5qt9BMgaJpZM4KCY4H.

JonnyBGod commented 7 years ago

Please try new version v0.3.0.

Make sure you read docs for new declaration system.

I will try to create more documentation and example during next week.