Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Double Brackets [[ ]] vs Double Braces {{ }} in Polymer

What's a succinct way to explain the difference between double brackets ([[...]]) and double braces ({{...}}) in Polymer 1.0?

For instance, in the documentation for the <iron-list> element the sample HTML shows:

<template is="dom-bind">
  <iron-ajax url="data.json" last-response="{{data}}" auto></iron-ajax>
  <iron-list items="[[data]]" as="item">
    <template>
      <div>
        Name: <span>[[item.name]]</span>
      </div>
    </template>
  </iron-list>
</template>

Why is data bounded by double braces in one spot (last-response="{{data}}") but bounded by double brackets (items="[[data]]") in another spot?

like image 852
George Avatar asked Aug 25 '15 04:08

George


People also ask

What are the curly brackets {{ }} used for?

In writing, curly brackets or braces are used to indicate that certain words and/or sentences should be looked at as a group. Here is an example: Hello, please pick your pizza toppings {chicken, tomatoes, bacon, sausage, onion, pepper, olives} and then follow me.

What are these {} brackets called?

The "{}" are referred to as curly brackets or braces while "<>" are often called angle brackets or braces. The term "curly braces" is more favored in the U.S., while "brackets" is more widely used in British English. The "()" are also frequently abbreviated as "parens" since they are parantheses characters.

Why do we use double brackets?

The double brackets, [[ ]], were introduced in the Korn Shell as an enhancement that makes it easier to use in tests in shell scripts. We can think of it as a convenient alternative to single brackets. It's available in many shells like Bash and zsh.

Are {} called braces?

Curly brackets {}Curly brackets, also known as braces or curly braces, are rarely used in formal writing and are more common in other fields such as science, math, and computing. Some style guides will allow them to be used for one specific purpose: grouping together a set.


1 Answers

Binding can be either one-way (using [[]]) or two-way (using {{}}, but also use notify).

To explain *-way binding think traffic. one-way binding is when you update model, the view gets updated. When the vice-versa is also true it is a two-way binding.

For more information see the documentation.

like image 177
user568109 Avatar answered Oct 06 '22 23:10

user568109