ui-sref

73 views
Skip to first unread message

pratik lodha

unread,
Jul 5, 2014, 1:25:51 PM7/5/14
to ang...@googlegroups.com
i want to send two states in ui-sref,

ui-sref="something1/something2" 

in my current state which is :

        .state('competitions',{
          url : '/competitions',
          parent : 'Events',
          templateUrl : 'views/genres/competitions.html',
          controller : 'Home'
        })
so i defined a state like this  
.state('intocompetitions',{
          url : '/:genre',
          parent : 'competitions',
          templateUrl : 'views/competitions/dance.html',
          controller : 'Home'
        })

it shows cannot resolve something1/something2 in the state competitions

Eric Eslinger

unread,
Jul 5, 2014, 1:36:42 PM7/5/14
to ang...@googlegroups.com
if you want to do something like foo/bar, with bar a substate of foo, use dots. 

.state('foo' ...)
.state('foo.bar ...)
then ui-sref="foo.bar"


e


--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

pratik lodha

unread,
Jul 5, 2014, 1:36:48 PM7/5/14
to ang...@googlegroups.com


On Saturday, 5 July 2014 22:55:51 UTC+5:30, pratik lodha wrote:
i want to send two states in ui-sref,

ui-sref="something1/something2" 

in my current state which is :

        .state('competitions',{
          url : '/competitions',
          parent : 'Events',
          templateUrl : 'views/genres/competitions.html',
          controller : 'Home'
        })
so i defined a state like this  
.state('intocompetitions',{
          url : '/:genre/:event',   
          parent : 'competitions',
          templateUrl : 'views/competitions/dance.html',
          controller : 'Home'
        })

pratik lodha

unread,
Jul 5, 2014, 1:48:21 PM7/5/14
to ang...@googlegroups.com
but foo/bar is variable for me ...and i want to store them 

url:":/genre/:event"


--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/kmytCtI98uE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.

pratik lodha

unread,
Jul 5, 2014, 1:49:16 PM7/5/14
to ang...@googlegroups.com
my ui-sref:
ui-sref="{{compi.name}}/{{event.name}}

Eric Eslinger

unread,
Jul 5, 2014, 2:04:23 PM7/5/14
to ang...@googlegroups.com
You specify state references with dots and not slashes. Then you specify the state parameters later. So, it would be something like

ui-sref="competitions.intocompetitions({genre: compi.name, event: event.name})"

If you have properly specified your states as substates, which is hard to tell as you have only provided part of your actual code. Personally, I define all four states down the line, to stick with foo and bar for my case (because I don't understand your routing setup from the fragment)

state: foo (url '/foo')
state: foo.detail (url '/:fooID')
state: foo.detail.bar (url '/bar')
state: foo.detail.bar.detail (url '/:barID')

with all the associated other stuff in your .state stack.

Then to display the actual bar of foo, I'd go to /foo/1/bar/2, which is ui-sref="foo.detail.bar.detail({fooID: 1, barID: 2})"

Also, I usually pluralize things (foos and bars).

Then to display all foos and all bars of a specific foo, that's defined on the foo and foo.detail.bar states (index vs show in rails routing terms). If that doesn't make sense, just declare foo and foo.detail.bar to be abstract states and you won't be able to transition in there.


e

pratik lodha

unread,
Jul 5, 2014, 4:40:45 PM7/5/14
to ang...@googlegroups.com
TY it worked .:)
Reply all
Reply to author
Forward
0 new messages