Ashley
Ashley

Reputation: 491

What is significance of params in html?

I'm trying to connect dots for a website code and stuck at this place.Can somebody pls explain what does this means in html, knockoutJS ?What is params used for and what is route here ?

<x-header params="route: route"></x-header>

Upvotes: 1

Views: 78

Answers (2)

Asnogordo
Asnogordo

Reputation: 56

A KnockoutJS component is registered (somewhere else) with the name x-header. When we want to use the x-header component, it uses the same syntax as a html tag, hence the mix up.

The paramsattribute is passing the value of a separate object named route (the right side of the colon). It just so happens that the name that it will be passed as will also be route (left side of the colon).

This params value is being passed to the x-header component's viewModel. It may looks something like this:

    function viewModelXHeader(params)
    {
       var self = this;
       self.route = params.route;
       <other stuff that uses self.route>
    }

The params attribute can be passed any number of parameters with a comma delimiter, and they are then available within the viewModel:

<x-header params="route: route, firstname: firstname, title: 'hello world'"></x-header>

Upvotes: 1

T.J. Crowder
T.J. Crowder

Reputation: 1074335

It's nothing in HTML. Somewhere in the code you'll find that a Knockout component has been defined which uses x-header as its tag name. The params attribute is just where the author of that component decided the parameters for it would be.

Upvotes: 0

Related Questions