I am trying to evaluate an expression inside expression using angularJS.Please let me know how to do it?
Problem:
I have two objects department and facility and i want to display departments and facilities in accordions. So, i am able to pass department object and facility object. Now the problem arises.As the department object has property department_name and facility has facility_name.I passed the department_name and facility_name to label attribute in directive and trying to use in accordion html like this {{item.{{label}}}}.I don't think this is right. But please let me know how can i do this.
Thanks in advance
In HTML:
<accordion-directive object="department" label="department_name">
</accordion-directive>
<accordion-directive object="facility" label="facility_name">
</accordion-directive>
In Accordion HTML
<accordion-group ng-repeat="item in object>
<accordion-heading>
{{item.{{label}}}} // For departments it should be department[0].department_name
// For Facility it should be facility[0].facility_name
</accordion-heading>
</accordion-group>
JSON file:
{
"department": [
{
"department_name": "department 1",
},
{
"department_name": "department 2",
}
]
}
{
"facility": [
{
"facility_name": "Facility 1"
},
{
"facility_name": "Facility 2"
}
]
}
Directive:
angular.module("app").directive('accordDirective', function () {
return {
restrict: 'E',
scope: {
object: '=',
label:'@'
},
templateUrl: 'accordian.html',
}