After the new version of the Angular, I can't find typings.d.ts in my src dir that's why I can't include types.
I have installed @types/jquery and @types/bootstrap - here's my package.json file:
"dependencies": {
"@angular/animations": "~7.1.0",
"@angular/common": "~7.1.0",
"@angular/compiler": "~7.1.0",
"@angular/core": "~7.1.0",
"@angular/forms": "~7.1.0",
"@angular/platform-browser": "~7.1.0",
"@angular/platform-browser-dynamic": "~7.1.0",
"@angular/router": "~7.1.0",
"@auth0/angular-jwt": "^2.1.0",
"@mdi/font": "^3.0.39",
"bootstrap": "^4.1.3",
"core-js": "^2.5.4",
"ehandler": "^0.2.1",
"ehttp": "^0.2.4",
"ng-click-outside": "^4.0.0",
"ngd-dropdown": "^0.2.5",
"popper.js": "^1.14.5",
"rxjs": "~6.3.3",
"toastr": "^2.1.4",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.11.0",
"@angular/cli": "~7.1.0",
"@angular/compiler-cli": "~7.1.0",
"@angular/language-service": "~7.1.0",
"@types/bootstrap": "^4.1.3",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/jquery": "^3.3.27",
"@types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.1.6"
}
My tsconfig.json file:
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
my example.component.ts file:
@Component({
selector: 'modal',
templateUrl: './modal.component.html',
styleUrls: ['./modal.component.scss']
})
export class ModalComponent implements OnInit , OnChanges {
constructor() { }
ngOnInit() {
$('#modal-' + this.modal).modal('show');
}
}
after some research, I found old ways
- declare let $: any;
- import * as $ from 'jquery'
but doing this doesn't allow me to use $('#modal-element').modal('show');
Error: error TS2339: Property 'modal' does not exist on type 'JQuery'. please help me. Thanx in advance
Comments
Post a Comment