Let’s say we I have one route and one target:
"routes": [{
"pattern": "modify",
"name": "modify",
"target": [
"master",
"modify"
]
}],
"targets": {
"modify": {
"viewName": "Modify",
"viewId": "modify",
"viewLevel": 2
}
}
So I can access the route by this.getRouter().navTo("modify")
, meanwhile I can access the target by this.getRouter().getTargets().display("modify")
. Both API can carry parameter by the second argument. It seems to achieve the same effect.
I can access target without defining a route for it. So I did not quite understand why I need a route?
display
displays the target view without changing the hash value in contrast to navTo
.
You can find more information in the tutorial "Display a Target Without Changing the Hash".
Both API can carry parameter by the second argument. It seems to achieve the same effect.
display
method is for the display
event handler. When the event is fired, the handler carries the data we passed earlier.navTo
is mandatory if the pattern actually awaits a parameter, e.g. if we've defined the pattern like this initially: "pattern": "modify/{id}"
. Check out "Navigate to Routes with Mandatory Parameters".