Skip to content

reference html data model

Angel Rego edited this page Mar 15, 2016 · 2 revisions

data-model

The name of the model to bind data in a template. This name is linked with a model, a controller and a template.

When the template is loaded, a controller with the same name gets data from the server and fills the model, and then, the controller flush the content in the model to the template.

Data-model can be dynamically configured when loading the template by using {{}} notation.

Syntax:

<tagName data-model="modelName"...> where tag name is any available html tag.

Examples:

<!-- bind template to car model (cars={vendor:"kia",model:"nadal", photo:"res/kia.jpg"}) -->
<div data-model="car">
  <p>{{vendor}}</p>
  <p>{{model}}</p>
  <p><img src="{{photo}}"</p>
</div>
<!-- bind template to car model,and get data from cars model AND external owner model -->
<div data-model="car">
  <p>{{vendor}}</p>
  <p>{{model}}</p>
  <p>owner: {{owner:lastName}},{{owner:firsName}}</p>
</div>
<!-- bind template to car model, but taking the name from the queryString -->
<div data-model="car-{{$queryString:carID}}">
  <p>{{vendor}}</p>
  <p>{{model}}</p>
  <p>owner: {{owner:lastName}},{{owner:firsName}}</p>
</div>

Clone this wiki locally