Angular 6 + jQuery + fullpage.js












1















I am trying to use fullpage.js without ngx-fullapge and I am facing some issues relating to imports:



First it seems that jquery does not work, even though the package is setup...



In a very simple AppComponent class definition I have:



import { Component, OnInit } from '@angular/core';
import * as $ from 'jquery';
import * as fullpagejs from 'fullpage.js';

@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ],
})
export class AppComponent implements OnInit {
public items = [1, 2, 3];

public ngOnInit() : void {
$('#fullpage')
}
}


with a very simple template:



<div id="fullpage">

<div class="section" id="landing">
Landing
</div>

<div class="section" *ngFor="let item of items; let i = index" id="document_{{ i }}">
Document {{ item }}
</div>

<div class="section" id="general-information">
General Information
</div>

</div>


And the angular.json has the scripts below:



 "scripts": [
"./node_modules/jquery/dist/jquery.min.js",
"./node_modules/fullpage.js/dist/jquery.fullpage.min.js"
]


And I have the error below:



ERROR
Error: $ is not a function


I created an online project here that reproduces the issue: https://stackblitz.com/edit/angular-nrrujn



How can I use both jQuery and fullpage.js in this project?



[EDIT]



jQuery works with import $ from 'jquery'; but the fullpage() method from fullpage.js still cannot be found.
I updated the stackblitz: https://stackblitz.com/edit/angular-nrrujn










share|improve this question

























  • Try adding declare var $: any to the AppComponent.

    – cgTag
    Jul 19 '18 at 0:21











  • Now fullPage.js is available for Angular: github.com/alvarotrigo/angular-fullpage

    – Alvaro
    Nov 15 '18 at 16:24
















1















I am trying to use fullpage.js without ngx-fullapge and I am facing some issues relating to imports:



First it seems that jquery does not work, even though the package is setup...



In a very simple AppComponent class definition I have:



import { Component, OnInit } from '@angular/core';
import * as $ from 'jquery';
import * as fullpagejs from 'fullpage.js';

@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ],
})
export class AppComponent implements OnInit {
public items = [1, 2, 3];

public ngOnInit() : void {
$('#fullpage')
}
}


with a very simple template:



<div id="fullpage">

<div class="section" id="landing">
Landing
</div>

<div class="section" *ngFor="let item of items; let i = index" id="document_{{ i }}">
Document {{ item }}
</div>

<div class="section" id="general-information">
General Information
</div>

</div>


And the angular.json has the scripts below:



 "scripts": [
"./node_modules/jquery/dist/jquery.min.js",
"./node_modules/fullpage.js/dist/jquery.fullpage.min.js"
]


And I have the error below:



ERROR
Error: $ is not a function


I created an online project here that reproduces the issue: https://stackblitz.com/edit/angular-nrrujn



How can I use both jQuery and fullpage.js in this project?



[EDIT]



jQuery works with import $ from 'jquery'; but the fullpage() method from fullpage.js still cannot be found.
I updated the stackblitz: https://stackblitz.com/edit/angular-nrrujn










share|improve this question

























  • Try adding declare var $: any to the AppComponent.

    – cgTag
    Jul 19 '18 at 0:21











  • Now fullPage.js is available for Angular: github.com/alvarotrigo/angular-fullpage

    – Alvaro
    Nov 15 '18 at 16:24














1












1








1








I am trying to use fullpage.js without ngx-fullapge and I am facing some issues relating to imports:



First it seems that jquery does not work, even though the package is setup...



In a very simple AppComponent class definition I have:



import { Component, OnInit } from '@angular/core';
import * as $ from 'jquery';
import * as fullpagejs from 'fullpage.js';

@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ],
})
export class AppComponent implements OnInit {
public items = [1, 2, 3];

public ngOnInit() : void {
$('#fullpage')
}
}


with a very simple template:



<div id="fullpage">

<div class="section" id="landing">
Landing
</div>

<div class="section" *ngFor="let item of items; let i = index" id="document_{{ i }}">
Document {{ item }}
</div>

<div class="section" id="general-information">
General Information
</div>

</div>


And the angular.json has the scripts below:



 "scripts": [
"./node_modules/jquery/dist/jquery.min.js",
"./node_modules/fullpage.js/dist/jquery.fullpage.min.js"
]


And I have the error below:



ERROR
Error: $ is not a function


I created an online project here that reproduces the issue: https://stackblitz.com/edit/angular-nrrujn



How can I use both jQuery and fullpage.js in this project?



[EDIT]



jQuery works with import $ from 'jquery'; but the fullpage() method from fullpage.js still cannot be found.
I updated the stackblitz: https://stackblitz.com/edit/angular-nrrujn










share|improve this question
















I am trying to use fullpage.js without ngx-fullapge and I am facing some issues relating to imports:



First it seems that jquery does not work, even though the package is setup...



In a very simple AppComponent class definition I have:



import { Component, OnInit } from '@angular/core';
import * as $ from 'jquery';
import * as fullpagejs from 'fullpage.js';

@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ],
})
export class AppComponent implements OnInit {
public items = [1, 2, 3];

public ngOnInit() : void {
$('#fullpage')
}
}


with a very simple template:



<div id="fullpage">

<div class="section" id="landing">
Landing
</div>

<div class="section" *ngFor="let item of items; let i = index" id="document_{{ i }}">
Document {{ item }}
</div>

<div class="section" id="general-information">
General Information
</div>

</div>


And the angular.json has the scripts below:



 "scripts": [
"./node_modules/jquery/dist/jquery.min.js",
"./node_modules/fullpage.js/dist/jquery.fullpage.min.js"
]


And I have the error below:



ERROR
Error: $ is not a function


I created an online project here that reproduces the issue: https://stackblitz.com/edit/angular-nrrujn



How can I use both jQuery and fullpage.js in this project?



[EDIT]



jQuery works with import $ from 'jquery'; but the fullpage() method from fullpage.js still cannot be found.
I updated the stackblitz: https://stackblitz.com/edit/angular-nrrujn







javascript jquery angular fullpage.js






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 21 '18 at 12:16







Ehouarn Perret

















asked Jul 18 '18 at 22:58









Ehouarn PerretEhouarn Perret

1,06011234




1,06011234













  • Try adding declare var $: any to the AppComponent.

    – cgTag
    Jul 19 '18 at 0:21











  • Now fullPage.js is available for Angular: github.com/alvarotrigo/angular-fullpage

    – Alvaro
    Nov 15 '18 at 16:24



















  • Try adding declare var $: any to the AppComponent.

    – cgTag
    Jul 19 '18 at 0:21











  • Now fullPage.js is available for Angular: github.com/alvarotrigo/angular-fullpage

    – Alvaro
    Nov 15 '18 at 16:24

















Try adding declare var $: any to the AppComponent.

– cgTag
Jul 19 '18 at 0:21





Try adding declare var $: any to the AppComponent.

– cgTag
Jul 19 '18 at 0:21













Now fullPage.js is available for Angular: github.com/alvarotrigo/angular-fullpage

– Alvaro
Nov 15 '18 at 16:24





Now fullPage.js is available for Angular: github.com/alvarotrigo/angular-fullpage

– Alvaro
Nov 15 '18 at 16:24












3 Answers
3






active

oldest

votes


















1














Update Nov 2018:



Now fullPage.js is available for Angular:
https://github.com/alvarotrigo/angular-fullpage





Not an expert on Angular but... perhaps you should declare $ on the window object after importing it?



What about this?



import { Component, OnInit } from '@angular/core';
import jQuery from 'jquery'; // <--- change here
import * as fullpagejs from 'fullpage.js';

if(!window.$){
window.$ = jQuery;
}





share|improve this answer





















  • 1





    import jQuery as $ from 'jquery'; is a syntax error. It doesn't even make sense to rename the default export. You ARE giving it a name.

    – Lazar Ljubenović
    Jul 21 '18 at 12:14











  • @LazarLjubenović agreed, this can be tested in the stackblitz.com/edit/angular-nrrujn

    – Ehouarn Perret
    Jul 21 '18 at 12:16











  • @LazarLjubenović yeah that shouldn't be there lol.

    – Alvaro
    Jul 23 '18 at 12:41



















2














Make sure you have jquery.fullpage.min.js file present in the directory = './node_modules/fullpage.js/dist/jquery.fullpage.min.js'






share|improve this answer
























  • Welcome to Stack Overflow! This post seems to be your first answer, and it contains code. Remember, you can add code blocks with markdown syntax and it seems much better. Check out this help center article.

    – sohnryang
    Sep 2 '18 at 12:44



















1














The line import * as $ from 'jquery'; is definitely correct.



Make sure that jquery is actually installed in your project. Run npm install jquery@latest to install it. Then remove it from the scripts array because it doesn't belong there.






share|improve this answer
























  • tried to reset to the latest version and remove the paths in the scripts... but same old =/

    – Ehouarn Perret
    Jul 19 '18 at 19:28











  • @EhouarnPerret Try looking in your package-lock.json file. Is jquery in there? and is it the right version?

    – A.S.
    Jul 19 '18 at 19:42











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51412089%2fangular-6-jquery-fullpage-js%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Update Nov 2018:



Now fullPage.js is available for Angular:
https://github.com/alvarotrigo/angular-fullpage





Not an expert on Angular but... perhaps you should declare $ on the window object after importing it?



What about this?



import { Component, OnInit } from '@angular/core';
import jQuery from 'jquery'; // <--- change here
import * as fullpagejs from 'fullpage.js';

if(!window.$){
window.$ = jQuery;
}





share|improve this answer





















  • 1





    import jQuery as $ from 'jquery'; is a syntax error. It doesn't even make sense to rename the default export. You ARE giving it a name.

    – Lazar Ljubenović
    Jul 21 '18 at 12:14











  • @LazarLjubenović agreed, this can be tested in the stackblitz.com/edit/angular-nrrujn

    – Ehouarn Perret
    Jul 21 '18 at 12:16











  • @LazarLjubenović yeah that shouldn't be there lol.

    – Alvaro
    Jul 23 '18 at 12:41
















1














Update Nov 2018:



Now fullPage.js is available for Angular:
https://github.com/alvarotrigo/angular-fullpage





Not an expert on Angular but... perhaps you should declare $ on the window object after importing it?



What about this?



import { Component, OnInit } from '@angular/core';
import jQuery from 'jquery'; // <--- change here
import * as fullpagejs from 'fullpage.js';

if(!window.$){
window.$ = jQuery;
}





share|improve this answer





















  • 1





    import jQuery as $ from 'jquery'; is a syntax error. It doesn't even make sense to rename the default export. You ARE giving it a name.

    – Lazar Ljubenović
    Jul 21 '18 at 12:14











  • @LazarLjubenović agreed, this can be tested in the stackblitz.com/edit/angular-nrrujn

    – Ehouarn Perret
    Jul 21 '18 at 12:16











  • @LazarLjubenović yeah that shouldn't be there lol.

    – Alvaro
    Jul 23 '18 at 12:41














1












1








1







Update Nov 2018:



Now fullPage.js is available for Angular:
https://github.com/alvarotrigo/angular-fullpage





Not an expert on Angular but... perhaps you should declare $ on the window object after importing it?



What about this?



import { Component, OnInit } from '@angular/core';
import jQuery from 'jquery'; // <--- change here
import * as fullpagejs from 'fullpage.js';

if(!window.$){
window.$ = jQuery;
}





share|improve this answer















Update Nov 2018:



Now fullPage.js is available for Angular:
https://github.com/alvarotrigo/angular-fullpage





Not an expert on Angular but... perhaps you should declare $ on the window object after importing it?



What about this?



import { Component, OnInit } from '@angular/core';
import jQuery from 'jquery'; // <--- change here
import * as fullpagejs from 'fullpage.js';

if(!window.$){
window.$ = jQuery;
}






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 15 '18 at 16:24

























answered Jul 19 '18 at 14:48









AlvaroAlvaro

27.9k18103244




27.9k18103244








  • 1





    import jQuery as $ from 'jquery'; is a syntax error. It doesn't even make sense to rename the default export. You ARE giving it a name.

    – Lazar Ljubenović
    Jul 21 '18 at 12:14











  • @LazarLjubenović agreed, this can be tested in the stackblitz.com/edit/angular-nrrujn

    – Ehouarn Perret
    Jul 21 '18 at 12:16











  • @LazarLjubenović yeah that shouldn't be there lol.

    – Alvaro
    Jul 23 '18 at 12:41














  • 1





    import jQuery as $ from 'jquery'; is a syntax error. It doesn't even make sense to rename the default export. You ARE giving it a name.

    – Lazar Ljubenović
    Jul 21 '18 at 12:14











  • @LazarLjubenović agreed, this can be tested in the stackblitz.com/edit/angular-nrrujn

    – Ehouarn Perret
    Jul 21 '18 at 12:16











  • @LazarLjubenović yeah that shouldn't be there lol.

    – Alvaro
    Jul 23 '18 at 12:41








1




1





import jQuery as $ from 'jquery'; is a syntax error. It doesn't even make sense to rename the default export. You ARE giving it a name.

– Lazar Ljubenović
Jul 21 '18 at 12:14





import jQuery as $ from 'jquery'; is a syntax error. It doesn't even make sense to rename the default export. You ARE giving it a name.

– Lazar Ljubenović
Jul 21 '18 at 12:14













@LazarLjubenović agreed, this can be tested in the stackblitz.com/edit/angular-nrrujn

– Ehouarn Perret
Jul 21 '18 at 12:16





@LazarLjubenović agreed, this can be tested in the stackblitz.com/edit/angular-nrrujn

– Ehouarn Perret
Jul 21 '18 at 12:16













@LazarLjubenović yeah that shouldn't be there lol.

– Alvaro
Jul 23 '18 at 12:41





@LazarLjubenović yeah that shouldn't be there lol.

– Alvaro
Jul 23 '18 at 12:41













2














Make sure you have jquery.fullpage.min.js file present in the directory = './node_modules/fullpage.js/dist/jquery.fullpage.min.js'






share|improve this answer
























  • Welcome to Stack Overflow! This post seems to be your first answer, and it contains code. Remember, you can add code blocks with markdown syntax and it seems much better. Check out this help center article.

    – sohnryang
    Sep 2 '18 at 12:44
















2














Make sure you have jquery.fullpage.min.js file present in the directory = './node_modules/fullpage.js/dist/jquery.fullpage.min.js'






share|improve this answer
























  • Welcome to Stack Overflow! This post seems to be your first answer, and it contains code. Remember, you can add code blocks with markdown syntax and it seems much better. Check out this help center article.

    – sohnryang
    Sep 2 '18 at 12:44














2












2








2







Make sure you have jquery.fullpage.min.js file present in the directory = './node_modules/fullpage.js/dist/jquery.fullpage.min.js'






share|improve this answer













Make sure you have jquery.fullpage.min.js file present in the directory = './node_modules/fullpage.js/dist/jquery.fullpage.min.js'







share|improve this answer












share|improve this answer



share|improve this answer










answered Sep 2 '18 at 12:39









Param MittalParam Mittal

214




214













  • Welcome to Stack Overflow! This post seems to be your first answer, and it contains code. Remember, you can add code blocks with markdown syntax and it seems much better. Check out this help center article.

    – sohnryang
    Sep 2 '18 at 12:44



















  • Welcome to Stack Overflow! This post seems to be your first answer, and it contains code. Remember, you can add code blocks with markdown syntax and it seems much better. Check out this help center article.

    – sohnryang
    Sep 2 '18 at 12:44

















Welcome to Stack Overflow! This post seems to be your first answer, and it contains code. Remember, you can add code blocks with markdown syntax and it seems much better. Check out this help center article.

– sohnryang
Sep 2 '18 at 12:44





Welcome to Stack Overflow! This post seems to be your first answer, and it contains code. Remember, you can add code blocks with markdown syntax and it seems much better. Check out this help center article.

– sohnryang
Sep 2 '18 at 12:44











1














The line import * as $ from 'jquery'; is definitely correct.



Make sure that jquery is actually installed in your project. Run npm install jquery@latest to install it. Then remove it from the scripts array because it doesn't belong there.






share|improve this answer
























  • tried to reset to the latest version and remove the paths in the scripts... but same old =/

    – Ehouarn Perret
    Jul 19 '18 at 19:28











  • @EhouarnPerret Try looking in your package-lock.json file. Is jquery in there? and is it the right version?

    – A.S.
    Jul 19 '18 at 19:42
















1














The line import * as $ from 'jquery'; is definitely correct.



Make sure that jquery is actually installed in your project. Run npm install jquery@latest to install it. Then remove it from the scripts array because it doesn't belong there.






share|improve this answer
























  • tried to reset to the latest version and remove the paths in the scripts... but same old =/

    – Ehouarn Perret
    Jul 19 '18 at 19:28











  • @EhouarnPerret Try looking in your package-lock.json file. Is jquery in there? and is it the right version?

    – A.S.
    Jul 19 '18 at 19:42














1












1








1







The line import * as $ from 'jquery'; is definitely correct.



Make sure that jquery is actually installed in your project. Run npm install jquery@latest to install it. Then remove it from the scripts array because it doesn't belong there.






share|improve this answer













The line import * as $ from 'jquery'; is definitely correct.



Make sure that jquery is actually installed in your project. Run npm install jquery@latest to install it. Then remove it from the scripts array because it doesn't belong there.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jul 19 '18 at 15:09









A.S.A.S.

18412




18412













  • tried to reset to the latest version and remove the paths in the scripts... but same old =/

    – Ehouarn Perret
    Jul 19 '18 at 19:28











  • @EhouarnPerret Try looking in your package-lock.json file. Is jquery in there? and is it the right version?

    – A.S.
    Jul 19 '18 at 19:42



















  • tried to reset to the latest version and remove the paths in the scripts... but same old =/

    – Ehouarn Perret
    Jul 19 '18 at 19:28











  • @EhouarnPerret Try looking in your package-lock.json file. Is jquery in there? and is it the right version?

    – A.S.
    Jul 19 '18 at 19:42

















tried to reset to the latest version and remove the paths in the scripts... but same old =/

– Ehouarn Perret
Jul 19 '18 at 19:28





tried to reset to the latest version and remove the paths in the scripts... but same old =/

– Ehouarn Perret
Jul 19 '18 at 19:28













@EhouarnPerret Try looking in your package-lock.json file. Is jquery in there? and is it the right version?

– A.S.
Jul 19 '18 at 19:42





@EhouarnPerret Try looking in your package-lock.json file. Is jquery in there? and is it the right version?

– A.S.
Jul 19 '18 at 19:42


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51412089%2fangular-6-jquery-fullpage-js%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Vorschmack

Quarantine