O'Reilly logo

Dart: Scalable Application Development by Ivo Balbaert, Sergey Akopkokhyants, Davy Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Polymer elements with JavaScript interop

In this recipe, we will show you how to work with a JavaScript object in a Polymer component. You can find the code in the project pol_js.

How to do it...

  1. The script starts with web\index.html, where a component with the name pol-js is imported through <link rel="import"href="pol_js.html"> and instantiated through <pol-js></pol-js>.

    From this, we know that the component is defined in pol_js.html, and its code is in a file named pol_js.dart. For a discussion of the other tags, refer to the first recipe.

  2. The index.html file also includes a JavaScript person.js object:
    function Person(name, gender) { this.name = name; this.gender = gender; this.greeting = function(otherPerson) { alert('I greet you ' + otherPerson.name); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required