简体   繁体   中英

Polymer 1.0 auto binding templates

I am trying to get auto binding template to work with out success. This is what I have done so far. The page doesn't render with the value of "greeting" . It outputs {{greeting}}.

<!doctype html>
<html lang="">
<head>

  <link rel="stylesheet" href="styles/main.css">
  <script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
  <link rel="import" href="bower_components/polymer/polymer.html">
</head>
<body>
   <template is="dom-bind" id="app" >
    <span>  {{greeting}} </span>
  </template>
  <script src="scripts/app.js"></script>
</body>
</html>

app.js

(function(document) {
  'use strict';
  var app = document.querySelector('#app');
  app.greeting = "Hello";

})(document);

It works with Polymer 0.5.5 http://plnkr.co/edit/fmL9xQEXKwnINzdL3rBj?p=preview

Your {{greeting}} binding must be the only content of a tag ( Polymer documentation: Binding to text content ). You need to remove the surrounding whitespace:

<template is="dom-bind" id="app" >
  <span>{{greeting}}</span>
</template>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM