1

I have two custom elements. student-details.html and student-service.html

student-details.html looks like this

<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="student-service.html">
<dom-module id="student-details">
<style>
</style>
<template>
 <h1>Student Details</h1>
<h1>{{studentId}}<h1> //This value is printed properly
 <student-service   user-data={{studentId}} service-name="StudentDetails"  response-data={{responseData}} ></student-service>



     <h1>{{responseData.name}}</h1>
     <img width="70" height="70" src="{{responseData.image}}" />
     <h1>{{responseData.qualification}}</h1>

     <h1>{{responseData.speciality}}</h1>
     <h1>{{responseData.phone}}</h1>

     <h1>{{responseData.email}}</h1>

     <template is="dom-repeat" items="{{responseData.addresses}}">
     <h1>{{item.street}}</h1>
     <h1>{{item.area}}</h1>
     </template>

</template>
<script>
Polymer({
is:'student-details',
properties:{
 studentId: String,
 notify: true
}

});

</script>
</dom-module>

the student-service takes input as studentId and returns a response in responseData.

If I access the value studentId in the student-details.html itself using {{studentId}} it displays, but I am not able to send the same value to user-data input in student-service element.

Note: If I hardcode the studentId, it works well. I think I am not following the proper way of passing value. Kindly suggest

RosAng
  • 1,010
  • 2
  • 18
  • 42

4 Answers4

0

Feel free to use iron-ajax

Using polymer ajax response

https://elements.polymer-project.org/elements/iron-ajax

I hope you can help.

Community
  • 1
  • 1
kyunghwanjung
  • 490
  • 6
  • 17
  • 1
    Hi the problem is not with iron-ajax. I have implemented iron-ajax in student-service.html and it works fine. My Issue is with passing the value studentId to the student-service element. – RosAng Jul 22 '15 at 09:38
0

You missed the quotes around {{studentId}}

Try:

<student-service user-data="{{studentId}}" service-name="StudentDetails"  response-data="{{responseData}}"></student-service>
Granze
  • 497
  • 1
  • 4
  • 10
0

You can try using <student-service user-data$="{{studentId}}" similar to this post.

Community
  • 1
  • 1
Erik Höhmann
  • 522
  • 4
  • 16
0

The code does not look wrong. It could well be that the student-service is being called before the studentId is set.

Try to see the flow of your code and make sure, the service is only called after the studentId is set.

RosAng
  • 1,010
  • 2
  • 18
  • 42