Topic: regarding using jquery pro version with angular
Shashi Shekhar Pathak pro asked 4 years ago
hi, I am using jquery pro in angular project and I am unable to use jquery functions .i am getting problems like pickadate(),materialSelect() is not defined kindly help.
zone-evergreen.js:172 Uncaught TypeError: $(...).materialSelect is not a function
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
Opened
Specification of the issue
- ForumUser: Pro
- Premium support: No
- Technology: MDB jQuery
- MDB Version: 4.12.0
- Device: desktop
- Browser: google chrome
- OS: windows
- Provided sample code: No
- Provided link: No
Bartłomiej Malanowski staff commented 4 years ago
Did you include MDB Pro in your project?
Shashi Shekhar Pathak pro commented 4 years ago
yes I have included the jquery pro version and everything is working perfectly all the CSS components , but the jquery functions are not working as I mentioned above.
Shashi Shekhar Pathak pro commented 4 years ago
Hii, I am waiting for the answer .kindly help
Arkadiusz Idzikowski staff commented 4 years ago
Please provide more information about your project configuration (package.json, angular.json content).
Also please update your question with an example html/ts code on which we will be able to reproduce this problem.
Shashi Shekhar Pathak pro commented 4 years ago
I have pasted the code of my angular.json, package.json and component file where I have used the jquery function to have a look.{ "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "newProjectRoot": "projects", "projects": { "wedding": { "projectType": "application", "schematics": {}, "root": "", "sourceRoot": "src", "prefix": "app", "architect": { "build": { "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "dist/wedding", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", "tsConfig": "tsconfig.app.json", "aot": false, "assets": [ "src/favicon.ico", "src/assets" ], "styles": [
"defaultProject": "wedding"}
//////////////////////////package.json
{ "name": "wedding", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "~8.2.14", "@angular/common": "~8.2.14", "@angular/compiler": "~8.2.14", "@angular/core": "~8.2.14", "@angular/forms": "~8.2.14", "@angular/platform-browser": "~8.2.14", "@angular/platform-browser-dynamic": "~8.2.14", "@angular/router": "~8.2.14", "jquery": "^3.4.1", "mdbootstrap-pro": "git+https://oauth2:\PRIVATE_TOKEN@git.mdbootstrap.com/mdb/jquery/jq-pro.git", "rxjs": "~6.4.0", "tslib": "^1.10.0", "zone.js": "~0.9.1" }, "devDependencies": { "@angular-devkit/build-angular": "~0.803.23", "@angular/cli": "~8.3.23", "@angular/compiler-cli": "~8.2.14", "@angular/language-service": "~8.2.14", "@types/node": "~8.9.4", "@types/jasmine": "~3.3.8", "@types/jasminewd2": "~2.0.3", "codelyzer": "^5.0.0", "jasmine-core": "~3.4.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~4.1.0", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~2.0.1", "karma-jasmine": "~2.0.1", "karma-jasmine-html-reporter": "^1.4.0", "protractor": "~5.4.0", "ts-node": "~7.0.0", "tslint": "~5.15.0", "typescript": "~3.5.3" }}
////////////////////////////app-component.ts
import { Component } from '@angular/core';//import {materialSelect} from "../../node_modules/mdbootstrap-pro/js//modules/material-select/material-select.min.js"import * as $ from '../../node_modules/jquery/dist/jquery.js'; declare var $: any;
@Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css']})export class AppComponent { title = 'wedding'; ngOnInit(){
// Material Select Initialization$(document).ready(function() { $('.mdb-select').materialSelect(); });
}
}
Shashi Shekhar Pathak pro commented 4 years ago
hey, buddy, you got the problem?
Arkadiusz Idzikowski staff commented 4 years ago
Where did you place the code responsible for materialSelect initialization? Please take a look at this thread and try to replace smooth scroll code with material select initialization in ngOnInit hook:
https://mdbootstrap.com/support/jquery/smooth-scrolling-not-working/