Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-ui-router.statehelper

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-ui-router.statehelper

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

  • 1.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
117
decreased by-50.63%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 13 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc