isCurrent
Check if data represents the current route.
route.isCurrent(data [,subsetMatch] )
Compares data
to the current route. Used to verify if an object is
representative of the current route.
The following example calls route.isCurrent
with a single matching parameter when route.data
has two properties. If subsetMatch
is false
or left default route.isCurrent
won't try and match subsets.
import {route} from "can";
route.data = {page: "recipes", id: "5"}; // location.hash -> "#!&page=recipes&id=5"
route.start();
setTimeout(() => {
const completeSet = route.isCurrent( {page: "recipes"} );
console.log( completeSet ); //-> false
const subSet = route.isCurrent( {page: "recipes"}, true );
console.log( subSet ); //-> true
}, 200);
Parameters
- data
{Object}
:Data to check against the current route.
- subsetMatch
{Boolean}
:If true,
route.current
will return true if every value indata
matches the current route data, even if the route data has additional properties that are not matched. Defaults tofalse
where every property needs to be present.
Returns
{Boolean}
:
Whether the data matches the current URL.