question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MdTooltip not working in Angular-CLI Project

See original GitHub issue

#I am trying to implement a tooltip using Angular 2’s material in an Angular-CLI project. The documentation is a little unclear on exactly what’s needed. All I need is a standard tooltip popup to show up.

My setup:

  • MacBook Air

  • OS X El Capitan (version 10.11.6)

  • Angular CLI Version: 1.0.0-beta.22-1

  • Node: 6.8.0

In my component HTML I have this:

<button md-raised-button mdTooltip="This is a tooltip!" mdTooltipPosition="below">Button</button>

In my app.module I have this (edited for brevity):

import { MaterialModule } from '@angular/material';

@NgModule({
    imports: [
        MaterialModule.forRoot(),
    ]

I also have material and hammer.js listed in my package.json (as hammer.js is apparently a dependency for the mdTooltip). Here’s my package.json:

{
  "name": "abc",
  "version": "0.0.1",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "2.2.3",
    "@angular/compiler": "2.2.3",
    "@angular/core": "2.2.3",
    "@angular/forms": "2.2.3",
    "@angular/http": "2.2.3",
    "@angular/material": "^2.0.0-beta.1",
    "@angular/platform-browser": "2.2.3",
    "@angular/platform-browser-dynamic": "2.2.3",
    "@angular/router": "3.2.3",
    "@types/socket.io": "^1.4.27",
    "@types/socket.io-client": "^1.4.29",
    "angular-in-memory-web-api": "~0.1.15",
    "angular2-chartjs": "^0.1.6",
    "chart.js": "^2.4.0",
    "core-js": "^2.4.1",
    "hammerjs": "^2.0.8",
    "ng2-charts": "^1.4.1",
    "rxjs": "5.0.0-beta.12",
    "socket.io": "^1.7.2",
    "socket.io-client": "^1.7.2",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.6.23"
  },
  "devDependencies": {
    "@angular/compiler-cli": "2.2.3",
    "@types/hammerjs": "^2.0.34",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "angular-cli": "1.0.0-beta.22-1",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "4.0.9",
    "ts-node": "1.2.1",
    "typescript": "~2.0.3",
    "typings": "^1.3.2",
    "webdriver-manager": "10.2.5"
  }
}

I’m unclear on what I need to also import into the component.ts file and what else, if anything, is needed to get this working. Here’s what I have for the component file now:

import { MaterialModule } from '@angular/material';
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-room',
  templateUrl: './room.component.html',
  styleUrls: ['./room.component.less']
})
export class RoomComponent implements OnInit {

  otherImg = 'app/img/avatar.svg';

  others = [
    { id: 1, name: 'John Smith' },
    { id: 2, name: 'Javier Sanchez' }
  ];

  chat(other) {
    console.log('Room chat function initiated...');
  }

  constructor() { }

  ngOnInit() {
  }

}

Right now I see a button in my component view. But no tooltip shows up when I hover over or click on the button. It shows the other material design elements (raised button styling, etc), but no tooltip.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:19 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
FitsnerAScommented, Dec 30, 2016

used md-tooltip insted mdTooltip

1reaction
alexandermikutacommented, Feb 22, 2017

@elainaRenee Yes, with a theme it works. But now my colors look strange. Do you know the name of the default-theme that is taken when no theme is included?

Read more comments on GitHub >

github_iconTop Results From Across the Web

MdTooltip not working in Angular-CLI Project #2449 - GitHub
I am trying to implement a tooltip using Angular 2's material in an Angular-CLI project. The documentation is a little unclear on exactly ......
Read more >
Using mdTooltip in Angular-CLI Project - Stack Overflow
I am trying to implement a tooltip using Angular 2's material in an Angular-CLI project. The documentation is a little unclear on exactly...
Read more >
How to use matTooltip in Angular Material ? - GeeksforGeeks
For showing the position we need to use the 'matTooltipPosition' ... Once done with the above steps then serve or start the project....
Read more >
Angular Material 10|9 Adding Tooltips with Options Tutorial by ...
In this Angular Material tutorial, we'll learn How to Add Tooltip using Material UI matTooltip component in the Angular 10/9/8/7/6/5/4 project.
Read more >
Tooltip Issue, Mattooltip Not Working In Angular - ADocLib
1) Setup Angular CLI. 2) Create an Angular Project. 3) Install Angular Material in project. 4) Import Material Modules. 5) Add a Basic...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found