Home Angular 8 Angular 8 bootstrap tooltip working example

Angular 8 bootstrap tooltip working example

by therichpost
Published: Updated: 8 comments
How to make business template with Bootstrap 4 and Angular 9?

Hello to all, welcome to therichpost.com. In this post, I will tell you, Angular 8 bootstrap tooltiop working example.

Here is the updated Angular 12 Bootstrap 5 Tooltip working code snippet link : Angular 12 Bootstrap 5 Tooltip

Here you can check Angular 11 Bootstrap 4 Tooltip Working Demo with Code Snippet:

Angular 8 bootstrap tooltip working example
Angular 8 bootstrap tooltip working example

Angular and bootstrap combination is amazing. This will be also use in Angular 7 and Angular 8.

Here are the complete working steps and please follow carefully:

1. Here are the basics commands to install angular 8 on your system:

npm install -g @angular/cli 

ng new angularpopup //Create new Angular Project

$ cd angularpopup // Go inside the Angular Project Folder

ng serve --open // Run and Open the Angular Project

http://localhost:4200/ // Working Angular Project Url

2. After done with above, you need to run below commands to set bootstrap environment into your angular 8 application:

npm install --save bootstrap

npm install jquery --save

npm install --save @types/jquery

npm install popper.js --save

3. Now you need to add below code into your angular.json file:

...
"styles": [
              "src/styles.css",
              "node_modules/bootstrap/dist/css/bootstrap.min.css"
          ],
"scripts": ["node_modules/jquery/dist/jquery.min.js", 
              "node_modules/popper.js/dist/umd/popper.min.js", 
              "node_modules/bootstrap/dist/js/bootstrap.min.js"
           ]
...

4. Now you need to add below code into your src/app/app.component.ts file:

import { Component } from '@angular/core';
declare var $:any;
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  ngOnInit() {
      $('[data-toggle="tooltip"]').tooltip();
  }
}

5. Now you need to add below code into src/app/app.component.html file:

<a href="#" data-toggle="tooltip" title="Hooray!">Hover over me</a>

In the end, don’t forgot to run ng serve command. If you have any query then do comment below.

Jassa

Thank you.

You may also like

8 comments

Carlos Alonso Casales Ortega February 3, 2020 - 8:46 pm

Works perfectly 😁👍

Reply
Ajay Malhotra May 9, 2020 - 6:55 am

Thank you

Reply
Chethan May 9, 2020 - 4:30 am

Is there any order we have follow in styles and script while including nodeModules

Reply
Ajay Malhotra May 9, 2020 - 6:56 am

You question is not clear to me.

Reply
Vishnupriya September 7, 2020 - 6:54 am

Perfect explanation. Thank you! But what if I want to add a content attribute in $(‘[data-toggle=”tooltip”]’).tooltip({ content: ‘Hooray’!}); and skip the title in the .html file? Will it still work?

Reply
Ajay Malhotra September 7, 2020 - 7:03 am

Thank you an yes, you can try it.

Reply
Pooja March 5, 2021 - 5:34 pm

i am getting this error :TypeError: $(…).tooltip is not a function

Reply
Ajay Malhotra March 6, 2021 - 5:16 am

You must missed something. Please check code again above.
Thanks

Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.