angular-ui-router
  • Introduction
  • Configuring State
  • Activating State
  • Named Views
  • Nested State
  • onEnter onExit
  • Passing Data
  • Resolve Property
  • State Params
  • State Service
  • State Events
  • Abstract State
Powered by GitBook
On this page

Was this helpful?

Passing Data

.state('activities', {
    url: '/activities',
    controller: 'AllActivitiesController',
    controllerAs: 'activities',
    templateUrl: '/app/templates/allActivities.html',
    data: {
        name: 'My Activity',
        desc: 'Fun'
    },
    foo: "my foooo"
})
  • Arbitrary property added to configuration object

  • Prototypically inherited by child states

Note

"data" could be anything

Access data/foo property in controller

.controller('ActivitiesCtrl', function($state){
    console.log($state.current.data); // object
    console.log($state.current.foo); // my foooo
})
PreviousonEnter onExitNextResolve Property

Last updated 5 years ago

Was this helpful?