37

I want to create a menu that looks like the one in AngularJs Material website (https://material.angularjs.org)

angularjs material menu

Unfortunately there is not documentation or demo to do that.

Any ideas?

Thanks

Claudio Ɯǝıs Mulas
  • 1,116
  • 3
  • 15
  • 24
  • the source for that page is completely open, you can see how it's implemented from the view source. – Claies Feb 08 '15 at 01:54
  • Not so completely open as you can see https://material.angularjs.org/docs.js – Claudio Ɯǝıs Mulas Feb 08 '15 at 01:57
  • It is open source … :| https://github.com/angular/material – Dan Rocha Feb 08 '15 at 03:05
  • 4
    Again? Yes, but in material angularjs website are used some customs directive and css that are not include in the project. Look in the source before comment. – Claudio Ɯǝıs Mulas Feb 08 '15 at 14:10
  • 3
    It's totally open. copy the menu service, and the 2 menu directives into your app, from here: https://github.com/angular/material/blob/master/docs/app/js/app.js#L132-L516 then grab the menu templates from here: https://github.com/angular/material/tree/master/docs/app/partials – konsumer Feb 09 '16 at 04:36

7 Answers7

32

You can create your own side menu with their directives menuToggle and menuItem, and their menu service, which are found in their source files. I have used this menu in many projects, so I know it works. All you have to do is implement it the same way. I have wrote a blog post that goes through this found here:

How to create an Angular Material Side Menu

britztopher
  • 1,214
  • 2
  • 16
  • 26
10

There are at least a few pre-built directives for this now... a couple of examples:

John Rix
  • 6,271
  • 5
  • 40
  • 46
3

As @Splaktar says, you can wait for the official mdListiItem in milestone 0.9.0.

And you can also checkout the whole angular-material project source code and look into here https://github.com/angular/material#building or README.md to build the docs.

First install or update your local project's npm tools:

# First install all the NPM tools:
npm install
# Or update
npm update

Then run the gulp tasks:

# To build `angular-material.js/.css` and `Theme` files in the `/dist` directory
gulp build
# To build the Angular Material Docs and Demos in `/dist/docs` directory
gulp docs

Then you should see the codes you need in 'docs.js', 'css/docs.css' and 'index.html' in the output folder 'dist/docs'.

The 'docs.js' in 'dist/docs' is different from the 'docs.js' in the origin 'docs' folder. Many codes are generated and concated together when you build the docs including those you need.

After you build the docs, the fastest way to get the codes you need is to search 'menuToggle' or 'menuLink' directive or 'menu' factory in 'dist/docs/docs.js'.

Hope this can help you.

futurexiong
  • 408
  • 4
  • 13
1

Just check out the answer here: https://stackoverflow.com/a/38258961/1904479,

The http://demo.sodhanalibrary.com/angular/material-ui/accordion/accordion.html has a good implementation of the accordion or the expandable list views.

Community
  • 1
  • 1
Kailas
  • 7,350
  • 3
  • 47
  • 63
1

You don't NEED any of this, if you want an identical UX and appearance, I guess there is no reason not to import the service and all. But, if all you want is the collapsability you could solve this with the ng-class directive without importing much; depending how you have your scope setup you might need a different variable for each collapsable zone, something like this:

<div data-ng-click="collapsableA = !collapsableA;">Toggle Click zone</div>
<div data-ng-class="{collapsed: 'collapsableA}" class="collapsable">
    Stuff that gets hidden
    <div>More stuff to hide</div>
</div>

In your controller $scope declarations

$scope.collapsedA = true //if you want it to start collapsed

and then in your css something like

.collapsable{
    transition: all .2s ease-in-out;
    min-height: 20px;
    overflow: hidden;
}
.collapsable.collapsed{
    height: 0;
    min-height: 0;
}
Andrew Clavin
  • 574
  • 2
  • 15
0

You will need to wait for mdListItem to support an expand/collapse control. This is tentatively scheduled for 0.9.0.

See https://github.com/angular/material/issues/985

Splaktar
  • 5,506
  • 5
  • 43
  • 74
-5

You could have a look at the accordion from angularui. http://angular-ui.github.io/bootstrap/

paje007
  • 1,001
  • 7
  • 9
  • 1
    Mixing Angular Material and Angular-ui isn't really a great idea if it can be avoided. Especially in the long term. – Mark Lenser Jan 11 '16 at 13:49