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:
- Created 7 years ago
- Comments:19 (3 by maintainers)
Top GitHub Comments
used md-tooltip insted mdTooltip
@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?