2014-07-02 51 views
3

我正在創建一個元素,它需要一個參數:userid。 在組件的模板中,我有一個core-ajax標記,它需要將該屬性作爲參數傳遞。如何在元素定義中將屬性傳遞給core-ajax?

我這樣做是這樣的:

<template attributes="userid"> 
    <core-ajax 
     auto 
     url="../../ajax/gettoday.php" 
     handleAs="json" 
     method="post" 
     params='{"userid": "{{userid}}"}' 
     response="{{today}}"></core-ajax> 
     ... 
</template> 

難道這就是接受PARAMS字符串中的屬性?

回答

4

attributes="userid"需要在<polymer-element>上,而不是元素的<template>。最上面的<template>什麼都不應該。

<polymer-element name="my-element" attributes="userid"> 

這個工作對我來說:http://jsbin.com/fihuyuga/1/edit

相關問題