Giter VIP home page Giter VIP logo

angular-material-sidenav's Introduction

angular-material-sidenav [NO MORE MAINTAINED]

Warning: this project is not maintained anymore. I've moved to React and stopped following Angular for the moment. However, I still watch the project for pull request

Simple component that reproduce the Angular Material Style SideNav Menu from their own website material.angularjs.org. Available Demo

1. Installation
bower install angular-material-sidenav --save
2. Configuration

add sasrio.angular-material-sidenav to your main module's list of dependencies

angular.module('myApp', ['sasrio.angular-material-sidenav'])

use the ssSideNavSectionsProvider as a provider to config your menu items

ssSideNavSectionsProvider.initWithSections([{
	id:		'toogle_1',
	name:	'Section Heading 1',
	type:	'heading',
	children: [{
		name:	'Toogle 1',
		type:	'toggle',
		pages:	[{
			id:		'toggle_item_1',
			name:	'item 1',
			state:	'common.toggle.item1'
		}, {
			id:		'toggle_item_2',
			name:	'item 2',
			state:	'common.toggle.item2'
		}]
	}]
}, {
	id:			'link_1',
	name:		'Simple link to Index state',
	state:		'common.index',
	type:		'link',
	hidden:	true // show menu ('true' for hide menu)
}]);

by default, if hidden property is not set, item will be displayed. So to hide one, just pass property to true.

Also, provide to module the $mdThemingProvider in order to get same colors

ssSideNavSectionsProvider.initWithTheme($mdThemingProvider);

You can check the demo source code of app.js to see more on how you can add items

3. Usage

In order to display your sidenav menu, use the factory ssSideNav to get all sections and send them into the directive , example :

note: update the components to the lastest as some of the implementations have changed (e.g method changeSectionVisible no more exist))

// in your controller, add the factory ssSideNav
angular.module('app.controller', [
	'$timeout',
  	'ssSideNav',
  	function ($timeout, ssSideNav) {
    	$scope.menu = ssSideNav;

		// Show or Hide menu
		ssSideNav.setVisible('link_1');
		ssSideNav.setVisibleFor([{
		  id: 'toggle_item_1',
		  value: true
		}, {
		  id: 'link_1',
		  value: false
		}]);

		$timeout(function () {
		  ssSideNav.setVisible('toogle_2', false);
		});

		$timeout(function () {
			// force selection on child dropdown menu item and select its state too.
			ssSideNav.forceSelectionWithId('toogle_1_link_2');
		}, 1000 * 3);
  }
]);

and of course, in your html view:

<ss-sidenav menu="menu"></ss-sidenav>
4. Customization

Colors are handle using a directive from the gist dh94 mdStyleColor

All sidenav is builded using the primary color configured with `$mdThemingProvider.

If you look the source code, you can easily add new template item, new kind of items and so on...

angular-material-sidenav's People

Contributors

dennisong avatar leosprikryl avatar musahaidari avatar nhmd avatar nicolasnimetz avatar pdorofiejczyk avatar renangaleno avatar sovanna avatar zack24q avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-material-sidenav's Issues

Unable to find suitable version for angular-ui-router

When I bower install angular-material-sidenav --save got

 "id": "ECONFLICT",
  "level": "error",
  "data": {},
  "message": "Unable to find suitable version for angular-ui-router",
  "stacktrace": "angular-ui-router: Unable to find suitable version for angular-ui-router\n    at createError (C:\\Users\\humen\\AppData\\Roaming\\nvm\\v4.4.7\\node_modules\\bower\\lib\\util\\createError.js:4:15)\n    at Manager._electSuitable (C:\\Users\\humen\\AppData\\Roaming\\nvm\\v4.4.7\\node_modules\\bower\\lib\\core\\Manager.js:823:15)\n    at C:\\Users\\humen\\AppData\\Roaming\\nvm\\v4.4.7\\node_modules\\bower\\lib\\core\\Manager.js:609:25\n    at _fulfilled (C:\\Users\\humen\\AppData\\Roaming\\nvm\\v4.4.7\\node_modules\\bower\\lib\\node_modules\\q\\q.js:834:54)\n    at self.promiseDispatch.done (C:\\Users\\humen\\AppData\\Roaming\\nvm\\v4.4.7\\node_modules\\bower\\lib\\node_modules\\q\\q.js:863:30)\n    at Promise.promise.promiseDispatch (C:\\Users\\humen\\AppData\\Roaming\\nvm\\v4.4.7\\node_modules\\bower\\lib\\node_modules\\q\\q.js:796:13)\n    at C:\\Users\\humen\\AppData\\Roaming\\nvm\\v4.4.7\\node_modules\\bower\\lib\\node_modules\\q\\q.js:556:49\n    at runSingle (C:\\Users\\humen\\AppData\\Roaming\\nvm\\v4.4.7\\node_modules\\bower\\lib\\node_modules\\q\\q.js:137:13)\n    at flush (C:\\Users\\humen\\AppData\\Roaming\\nvm\\v4.4.7\\node_modules\\bower\\lib\\node_modules\\q\\q.js:125:13)\n    at nextTickCallbackWith0Args (node.js:420:9)"
}]

ui-router dependency

Hi,

Currently it seems the menu is entirely dependent on ui-router, and that every menu link corresponds to a state. Is there any way to forgo that for certain links and instead just have an external URL? For example, I have some internal states but I also want to link out to a few other websites.

It doesn't work

the steps I do:
1.

 <link rel="stylesheet" href="/css/liveadmin/lib/angular-material.css" />
  <link rel="stylesheet" href="/css/liveadmin/lib/angular-material-sidenav.css>
<script src="angular/angular.min.js"></script>
<script src="/angular/angular-material.min.js"></script>
<script src="angular/angular-animate.min.js"></script>
<script src="angular/angular-ui-router.min.js"></script>
<script src="angular/angular-touch.min.js"></script>
<script src="angular/angular-material-sidenav.js"></script>
<script src="js/app.js"></script>

app.js:

`app = angular.module "guildApp",
    ['ui.router',
     'sasrio.angular-material-sidenav'
    ]
app.config (ssSideNavSectionsProvider)->
    ssSideNavSectionsProvider.initWithSections([{
        id:     'toogle_1',
        name:   'Section Heading 1',
        type:   'heading',
        children: [{
            name:   'Toogle 1',
            type:   'toggle',
            pages:  [{
                id:     'toggle_item_1',
                name:   'item 1',
                state:  'common.toggle.item1'
            }, {
                id:     'toggle_item_2',
                name:   'item 2',
                state:  'common.toggle.item2'
            }]
        }]
        }, {
            id:         'link_1',
            name:       'Simple link to Index state',
            state:      'common.index',
            type:       'link',
            hidden: true
        }]);
app.controller "indexCtrl", ($scope, $timeout, ssSideNav)->
    $scope.hello = "hello wrold"
    ($timeout, ssSideNav)->
        $scope.menu = ssSideNav;
        ssSideNav.setVisible('link_1');
        ssSideNav.setVisibleFor([{
          id: 'toggle_item_1',
          value: true
        }, {
          id: 'link_1',
          value: false
        }]);
        $timeout( ->
            ssSideNav.setVisible('toogle_2', false);
        )

        $timeout(
            ->
                ssSideNav.forceSelectionWithId('toogle_1_link_2')
            , 1000 * 3);

  1. html
<div ng-app="guildApp">
          <div ui-view layout="row" flex></div>
        <ss-sidenav menu="menu"></ss-sidenav>
        <div ng-controller="indexCtrl">
            {{hello}}
            <ss-sidenav menu="menu"></ss-sidenav>

        </div>

    </div>

but it doesn't work.....

support for adding icons

any support for adding icons? like this
{
id: 'link_1',
name: 'Link 1 ',
state: 'common.link1',
type: 'link',
icon: 'fa fa-check'
}

Toggle menu bug

Hi.

If reload page on child state of toggle item, toggle section will close and ul height will 0.

Scroll in Firefox doesnt work

Scroll in Firefox and Edge doesn´t works, but in chrome works fine.

why??

How can I fix the issue?

Two examples.

ff
chrome

Maintaining menu selection for multiple or child states

This is great thank you! It saved me heaps of time I would have head to spend to make my own version of this.

I have a set of states which I want to all be grouped under a single sidenav link. Clicking the link should open up the primary state, but I would like it so that when any of those states are loaded that menu link is selected.

At the moment if my menu link is "Customers" and clicking it loads the customers state (/customers), and then clicking on a customer entry loads the customers.edit state (/customers/1) the menu link will still be selected, but if I refresh the page (loading url /customers/1) the sidenav will load in an unselected state, when I would like the Customers menu link to still be selected.

It would be ideal if we could define a single action-state and an array of selection-states for each link, such that the action state is used when the link is clicked but the selection-states are used to determine when the link will be selected/highlighted.

Issue with Pages

Hello,
First, I would thank for this library.
I'm facing an issue to display more than one page under toggle.

With this code following, only Item 1 is displayed :
{ name:"Toogle 1", type:"toggle", pages: [ { id:"toogle_1_link_1", name:"item 1", state:"common.toggle1.item1" }, { id:"toogle_1_link_2", name:"item 2", state:"common.toggle1.item2" }, { id:"toogle_1_link_3", name:"item 3", state:"common.toggle1.item3" } ] }

If I put Page as hidden, Item 2 will display.
Any idea?
Thank you.

'main' section in package.json

I'm not sure the 'main' section in your package.json is necessary when packaging angular modules. When installing it via npm, being an array instead of a single value causes an error and the installation fails.

How to have ng-click and external link in side nav

I need to have ng-click and external link in side nav

like
<a ng-click="callMyFunction(1)">Call 1</a>
<a ng-click="callMyFunction(2)">Call 2</a>

and
<a href="http://google.com/" target="_blank">Google</a>

angular-material version

Hi Sovanna,
im using angular-material "~0.10.1", and angularjs "~1.4",
and getting : Error: [$injector:unpr] Unknown provider: ssSideNavSectionsProvider
can you adapt this?
sorry for my poor english.

Unable add 3rd or 4th level sub menu

I am trying to third level sub menu like, but this does not work

ssSideNavSectionsProvider.initWithSections([{ name: '', type: 'heading', children: [{ name: 'Toogle 1', type: 'toggle', pages: [{ name: 'item 1', state: 'common.toggle1.item1' }, { name: 'item 2', state: 'common.toggle1.item2' },{ name: 'item 3', type: 'toggle', pages: [{ name: 'item 1', state: 'common.toggle1.item1' }] }] }] }, { name: 'Simple link to Index state', state: 'common.index', type: 'link' }]);

Could you help me here.

Implementing multilevel navigation

Hi sovanna, this plugin in awesome..i need to implement multilevel navigation like for example

  • Customers
    • Country
      • USA
        • State

          Alabama
          Atlanta
          Newyork

I'm able to get the first level items to get display it properly, but its not displaying its child item. Can you help me with it.

Thanks
Selva

Doesn't close on selection

Love your component and I'm using it now. One problem I see is: when the side-menu is open in collapsible mode, it does not automatically collapse again when a menu item is selected. For example, with the top-nav showing, resize the browser window to small and collapse the side-nav. Click on the md-icon=menu and then select an item after the side-nav expands. The side-nav will not automatically collapse.

Thanks again for this wonderful directive.

Reload state option

I need to reload controller.
like this

<a ui-sref="app.details" ui-sref-opts="{reload: true}">Details</a>

But ssSideNav look like how to add reload option

     icon:   'icon-trending',
     type:   'link',
     state:  'app.details'

ssSideNav.selectSection doesn't work

I assume ssSideNav.selectSection should open a section? I am adding following code to _common.js

$timeout(function () {
            alert('select common.toggle1.item1')
            ssSideNav.selectSection('common.toggle1.item1');
            //ssSideNav.selectSection('toogle_1_link_1'); //both don't work

}, 4000);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.