• Stars
    star
    235
  • Rank 170,016 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A helper module for AngularUI Router, which allows you to define your states as an object tree.

ui-router.stateHelper

A helper module for AngularUI Router, which allows you to define your states as an object tree.

Installation

  1. bower install angular-ui-router.stateHelper or npm install angular-ui-router.statehelper
  2. Reference stateHelper.min.js.
  3. Add a dependency on ui.router.stateHelper in your app module.

Usage

// NOTE: when using child states with views you should make sure that its parent has a template containing a `ui-view` directive.
angular.module('myApp', [ 'ui.router', 'ui.router.stateHelper' ])
    .config(function(stateHelperProvider){
        stateHelperProvider
            .state({
                name: 'root',
                templateUrl: 'root.html',
                children: [
                    {
                        name: 'contacts',
                        template: '<ui-view />',
                        children: [
                            {
                                name: 'list',
                                templateUrl: 'contacts.list.html'
                            }
                        ]
                    },
                    {
                        name: 'products',
                        templateUrl: 'products.html',
                        children: [
                            {
                                name: 'list',
                                templateUrl: 'products.list.html'
                            }
                        ]
                    }
                ]
            })
            .state({
                name: 'rootSibling',
                templateUrl: 'rootSibling.html'
            });
    });

Options

  • keepOriginalNames (default false)
  • siblingTraversal (default false)

Dot notation name conversion

By default, all state names are converted to use ui-router's dot notation (e.g. parentStateName.childStateName). This can be disabled by calling .state() with options options.keepOriginalNames = true. For example:

angular.module('myApp', ['ui.router', 'ui.router.stateHelper'])
	.config(function(stateHelperProvider){
		stateHelperProvider.state({
			name: 'root',
			templateUrl: 'root.html',
			children: [
				{
					name: 'contacts',
					templateUrl: 'contacts.html'
				}
			]
		}, { keepOriginalNames: true });
	});

Sibling Traversal

Child states may optionally receive a reference to the name of the previous state (if available) and the next state (if available) in order to facilitate sequential state traversal as in the case of building wizards or multi-part forms. Enable this by setting options.siblingTraversal = true.

Example:

angular.module('myApp', ['ui.router', 'ui.router.stateHelper'])
	.config(function(stateHelperProvider){
		stateHelperProvider.state({
			name: 'resume',
			children: [
				{
					name: 'contactInfo',
				},
				{
					name: 'experience',
				},
				{
					name: 'education',
				}
			]
		}, { siblingTraversal: true });
	});

console.log($state.get('resume.contactInfo').previousSibling) // undefined
console.log($state.get('resume.contactInfo').nextSibling) // 'resume.experience' 

console.log($state.get('resume.experience').previousSibling) // 'resume.contactInfo' 
console.log($state.get('resume.experience').nextSibling) // 'resume.education' 

console.log($state.get('resume.education').previousSibling) // 'resume.experience' 
console.log($state.get('resume.education').nextSibling) // undefined

Name change

Before 1.2.0 .setNestedState was used instead of .state. In 1.2.0 setNestedState was deprecated in favour of .state, and chaining was added. This makes it easier to switch between $stateProvider and stateHelperProvider.

More Repositories

1

node-toogoodtogo-watcher

Node.js cli tool for monitoring your favorite TooGoodToGo businesses. Docker image available.
JavaScript
359
star
2

lodash-deep

Lodash mixins for (deep) object accessing / manipulation.
JavaScript
223
star
3

node-pm2-windows-startup

Utility to make PM2 automatically resurrect on Windows startup
JavaScript
210
star
4

angular-recursion

A service which makes it easy possible to have recursive Angular directives.
JavaScript
176
star
5

WinLess

An awesome Windows GUI for less.js
C#
132
star
6

gulp-ng-html2js

Gulp plugin for compiling the HTML files of your Angular app to Javascript.
JavaScript
112
star
7

node-start-on-windows-boot

Simple utility to enable / disable starting a program on Windows boot, by modifiying the right registry values.
JavaScript
58
star
8

jquery.tabbable

Simple utility for selecting the next / previous ':tabbable' element.
JavaScript
47
star
9

obs-scene-execute-command-script

OBS script for executing any CLI command whenever whenever a scene is activated
Lua
28
star
10

node-transip-dns-cli

Node.js cli tool for updating TransIP DNS entries, including DDNS. Docker image available.
JavaScript
21
star
11

node-onvif-ptz-cli

Node.js cli tool for controlling PTZ cameras via the ONVIF protocol. Docker image available.
JavaScript
18
star
12

angular-class

An angular service for creating classes
JavaScript
16
star
13

docker-compose-homeassistant

Docker Compose example repository based on my home server setup, which runs on a Raspberry Pi.
Shell
9
star
14

mediawiki-dia

A MediaWiki extension which renders .dia files as .svg.
PHP
2
star
15

node-ibood-watcher

Node script to check ibood.com for new products during a 'hunt'.
JavaScript
1
star
16

angular-material-multi-level-sidenav-examle

Created with StackBlitz ⚑️
TypeScript
1
star
17

meat-fan

BBQ Fan Controller design with ESPHome firmware
1
star
18

webdriverio-wait-and

JavaScript
1
star
19

marklagendijk.nl

My personal website
TypeScript
1
star
20

node-istock-balance-scraper

Scrapes your current balance from you iStock account
JavaScript
1
star