ui-state-loader
v1.1.1
Published
Angular UI Router state definition loader
Downloads
5
Readme
ui-state-loader
Angular UI Router state definition loader
Extract and Exports state definition from source
Installation
$ npm install ui-state-loader --save
Usage
some-state.js
const angular = require('angular');
angular.module('myApp', [
require('angular-ui-router')
]).config(['$stateProvider', function($stateProvider) {
$stateProvider.state('foo', {
url: '/foo',
controller: 'FooCtrl',
template: require('./foo.jade'),
abstract: true
});
$stateProvider.state('foo.bar', {
url: '/bar',
controller: 'BarCtrl',
template: '<p>Page bar</p>'
});
}]).config(['$stateProvider', function($stateProvider) {
$stateProvider.state('foo.baz', {
url: '/baz',
controller: 'BazCtrl',
template: '<p>Page baz</p>'
});
}]);
const states = require('ui-state!./some-state');
/*
Equal as
const states = [{
name: 'foo',
url: '/foo',
controller: 'FooCtrl',
// template: require('./foo.jade'), // @note ignores CallExpression
abstract: true
}, {
name: 'foo.bar',
url: '/bar',
controller: 'BarCtrl',
template: '<p>Page bar</p>'
}, {
name: 'foo.baz',
url: '/baz',
controller: 'BazCtrl',
template: '<p>Page baz</p>'
}];
*/
License
See full license on mooyoul.mit-license.org