angularjs - Accessing parameters in custom data -


i'm using custom data add human readable name states, this:

.state('data', {   parent: 'week',   url: '/data',   displayname: 'data overview', 

i can use in template this:

<h1>showing {{$state.current.displayname}}</h1> 

which nice. want create route parameter, , use parameter in displayname:

.state('upload', {   parent: 'week',   url: '/upload/:level',   displayname: 'data upload ' + level,   ... 

but can't figure out correct syntax use access value of level inside displayname.

the static data (suggested placed inside of data : {} - not directly on root state settings) - static data. so:

there no way how set these data dynamically. e.g. based on $stateparams. these settings expected defined in .config() phase, not evaluated in .run()(in compariosn others resolve, templateurl...)

see doc:

attach custom data state objects

you can attach custom data state object (we recommend using data property avoid conflicts).

// example shows object-based state , string-based state var contacts = {      name: 'contacts',     templateurl: 'contacts.html',     data: {         customdata1: 5,         customdata2: "blue"     }   } $stateprovider   .state(contacts)   .state('contacts.list', {     templateurl: 'contacts.list.html',     data: {         customdata1: 44,         customdata2: "red"     }    }) 

with above example states access data this:

function ctrl($state){     console.log($state.current.data.customdata1) // outputs 5;     console.log($state.current.data.customdata2) // outputs "blue"; } 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -