angular


Angular 2 Material MD Menu is not working


I have imported "MdMenuModule" in my root and trying to use md-menu, it is not working.
<button md-icon-button [mdMenuTriggerFor]="menu">
<span> Menu </span>
</button>
<md-menu #menu="mdMenu">
<button md-menu-item>
<span>Redial</span>
</button>
<button md-menu-item disabled>
<span>Check voicemail</span>
</button>
<button md-menu-item>
<span>Disable alerts</span>
</button>
</md-menu>
But it's throwing following error.
Unexpected module 'MdMenuModule' declared by the module 'SharedModule'. Please add a #Pipe/#Directive/#Component annotation.
you clearly imported the MdMenuModule in the wrong place in your module called 'SharedModule'. So you should simply move the MdMenuModule declaration from the declarations array to the imports array as it's a module not a component or a directive or a pipe.
#NgModule({
declarations: [
//Components, Pipes or Directives here, remove the MdMenuModule
],
imports: [
//add it here
MdMenuModule
],
providers: [
//services go here
]
})
export class SharedModule{ }
Add in your app.module.ts
import { NgModule } from '#angular/core';
import { MaterialModule } from '#angular/material';
#NgModule({
imports: [
....
MaterialModule,
....
]
})

Related Links

Angular 2 / Ionic 2 post request body
Angular 2 Http-Post is not working
Property 'subscribe' does not exist on type 'Promise'
Angular4- on change select box returns wrong value
AOT Compilation error in angular library
Angular, Ionic2 Configure #ViewChild every time it is initialized
Angular ViewContainerRef and its ViewRefs - dynamic versus declarative?
Setting one parameter to a certain value upon entering a different parameter - NgSwitch?
Angular 2 page transition while leaving page
Adding the Multiselect feature to an Angular4 dropdown?
Add lines of code depending on folder structure - Precompiler?
Angular2 Rxjs Observable catch method compilation error
Partial file loader for translations [on hold]
How to pass data from modal to component?
Angular code diference between source code and debugger code
Angular2 cannot use the values of a subscribe in another subscribe (observable)

Categories

HOME
gnuplot
gradle
processing
dll
sails.js
rx-java
datastax
masonry
bitcoin
houndify
filesystems
iis-8
apache-apex
codeception
windows-authentication
bpm
cllocationmanager
border
4d-database
pyside
konvajs
couchbase-view
flip-flop
jsx
mpeg
footable
neo4jclient
white
radius
jqassistant
spring-4
jquery-ui-autocomplete
ggiraph
gmail-contextual-gadgets
nonetype
lift
instrumentation
winlims
sp-executesql
android-datepicker
lab-color-space
snobol
sift
icingaweb2
miva
nosuchelementexception
optional
google-chartwrapper
news-feed
git-stash
pubsubhubbub
reportviewer2008
webtorrent
mapfragment
owner
archiving
ratchet
antivirus-integration
iis-8.5
sos
mime-mail
network-monitoring
mks-integrity
meter
eofexception
uiactivity
wave
google-text-to-speech
grunt-contrib-cssmin
review
zenoss
image-manipulation
navigationbar
comfortable-mexican-sofa
typescript1.4
tracker
data-sharing
sharepoint-clientobject
teamsite
form-helpers
start-stop-daemon
triples
factoring
delphiscript
mib
amber-smalltalk
grit
jlayer
cocos2d-python
windows-live-writer
fql.multiquery
context-sensitive-help
language-theory
blogml
ipod-nano
incremental-linking
tibco-gi
orbited

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile