Angular 2 Tutorial 22 | pathMatch | TutorialsPoint [w/ subs]



00:00:00 – all right everybody welcome to your 23rd
00:00:04 – angular tutorial in which we're going to
00:00:06 – take a look at what path match is in
00:00:09 – angular and why would you probably need
00:00:13 – that though actually you wouldn't
00:00:15 – require path match all the time but I
00:00:19 – guess in some case if you need that then
00:00:22 – you should know what that is or if you
00:00:24 – at least read it on somebody else good
00:00:27 – so path match is essentially just
00:00:29 – telling angular whether you want to
00:00:32 – continue with a route or not if the
00:00:34 – parent route matches right so what
00:00:37 – essentially angular is doing behind the
00:00:39 – scenes is that when you revisit a URL
00:00:41 – something like this angular decides okay
00:00:44 – so I'll just break this URL into parts
00:00:47 – first of all I see this users right so
00:00:50 – I'm going to look for the users okay
00:00:52 – angular says yeah there we find we have
00:00:54 – the users all right now angular would
00:00:57 – look at the path match right so we have
00:01:01 – this property fast match which is by
00:01:05 – default prefix now angular would look at
00:01:07 – this property this is set and would
00:01:10 – consider this as prefix if it does not
00:01:12 – set now what prefix means is that
00:01:15 – angular is taking a look at the part of
00:01:17 – the URL and says okay that thing matches
00:01:19 – but what about the else what about the
00:01:21 – rest of the URL so with the prefix
00:01:24 – angular takes it one at a time if the
00:01:27 – path matches a little bit in the
00:01:29 – stunting angular says okay I'm going to
00:01:31 – continue running this part and take a
00:01:34 – look if it matches of course if you'd
00:01:36 – rather consumes the full URL or not
00:01:39 – right so in our case it matches the user
00:01:42 – so it will just continue searching for
00:01:44 – children or any other particular match
00:01:47 – then we have this methyl amputee which
00:01:50 – inside our children matches these two
00:01:53 – both of these right now angular has to
00:01:56 – decide again which one it has to go with
00:01:58 – again we have this idea right now which
00:02:01 – is five so angular sees that this has
00:02:04 – got our perfect route and it has
00:02:07 – consumed all of the part of the routes
00:02:09 – so we're going to go with this one
00:02:11 – all right so far so good but what
00:02:14 – happens if we make this full instead now
00:02:18 – if I say this and go to the stage you
00:02:22 – can rather see that we get full or not
00:02:24 – sound and the reason for that is that
00:02:27 – instead of matching it one at a time
00:02:30 – angular stays if this lungs matches I'm
00:02:34 – going to go with it otherwise I'm going
00:02:36 – to leave it at all so it goes to users
00:02:39 – well it does match user but apparently
00:02:42 – it is not the full match right so this
00:02:46 – would pretty much just match localhost
00:02:51 – and then users right so it would just
00:02:54 – match local host users with a path match
00:02:57 – of both but the paths match of prefix it
00:02:59 – will match the users and then it will
00:03:01 – check if it actually consumes the whole
00:03:04 – URL or not but right now without match
00:03:06 – of full it just stops if the URL is not
00:03:09 – completely consumed so yeah that is how
00:03:13 – pretty much part match works in a
00:03:16 – nutshell and I don't think we really
00:03:19 – need to explicitly set it all the time
00:03:21 – maybe there are some use cases but I
00:03:24 – haven't come across them yet
00:03:26 – so yeah that's all for this one and if
00:03:29 – you liked it then please don't forget to
00:03:31 – subscribe and thank you for watching
00:03:32 – I'll see you then in the next one


Video Url:
http://youtu.be/xAJaafr-onA

Comments

comments