我有两个自定义元素。学生details.html和学生service.html如何在Polymer 1.0中将值从一个自定义元素传播到另一个自定义元素?
学生details.html看起来像这样
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="student-service.html">
<dom-module id="student-details">
<style>
</style>
<template>
\t <h1>Student Details</h1>
<h1>{{studentId}}<h1> //This value is printed properly
\t <student-service user-data={{studentId}} service-name="StudentDetails" response-data={{responseData}} ></student-service>
\t <h1>{{responseData.name}}</h1>
\t <img width="70" height="70" src="{{responseData.image}}" />
\t <h1>{{responseData.qualification}}</h1>
\t <h1>{{responseData.speciality}}</h1>
\t <h1>{{responseData.phone}}</h1>
\t <h1>{{responseData.email}}</h1>
\t <template is="dom-repeat" items="{{responseData.addresses}}">
\t <h1>{{item.street}}</h1>
\t <h1>{{item.area}}</h1>
\t </template>
</template>
<script>
Polymer({
is:'student-details',
properties:{
\t studentId: String,
\t notify: true
}
});
</script>
</dom-module>
学生服务需要输入作为studentId并返回responseData响应。
如果我使用{{studentId}}访问student-details.html中的值studentId,它会显示,但我无法将相同的值发送到student-service元素中的用户数据输入。
注意:如果我硬编码studentId,它运作良好。 我认为我没有遵循传递价值的正确方式。请建议
你是对的,我在studentId被设置之前打电话给服务。 – RosAng