This topic contains 1 reply, has 2 voices, and was last updated by Sean Sean 1 year, 11 months ago.

Passing Parameters to controllers and views in Angular


  • jkdoyle
    Participant

    Posts: 3
    Member Reply #6804

    I’m trying to figure out how to pass parameters to state views in  the angular versions.  I’ve tried using the following formats:

    url: ‘/pagelink/:myParam1/:myParam2’ as well as url: ‘/pagelink?myParam1&myParam2

    but I can’t seem to figure out how to access these parameters from the controller (LoadPageController which I copied from GeneralPageController) or on the view page.

    If I initialize and set parameters using param: { myParam1: ‘this is it’, myParam2: ‘another’} I can access them on the view page using {{$state.current.param.myParam1}}.  However, I want to pass these on the link dynamically and then use them at the $root level (setting them in the controller).  What am I missing?  What is the format for the params object if I want to access them from the controller?  (I’ve tried $routeParams as well).

    Thanks
    JD

    Sean
    Sean
    Keymaster

    Posts: 4435
    Support Staff Reply #6813

    Hi :),

    Can you please check below link:
    https://scotch.io/tutorials/3-simple-tips-for-using-ui-router

    Thanks.

You must be logged in to reply to this topic.