How to set a parent property from within a custom element in Aurelia? -


a few days ago asked question 2 way databinding in aurelia custom elements - bind custom element parent viewmodel

now need able reuse allselectablevalues custom element (my-custom.js) in parent element (create.js).

i need custom value converter have on create.js contains ids need display names instead, looping through array of elements, fetched , residing in custom element.

**create.html** <td>${d.someid | allselectablevaluesmapping}</td> 

and

**value-converters/all-selectable-values-mapping.js** export class allselectablevaluesmappingvalueconverter {     toview(value) {         for(let item in allselectablevalues) {             if (item.someid == value){                 return item.name;             }         }      } } 

in ideal world i'd have hoped have worked:

**my-custom.js** async attached() {     this.allselectablevalues= await await this.myservice.getallvalues();     this.parent.allselectablevalues = this.allselectablevalues; } 

but custom element have no idea of parent requiring it.

does have idea how set parent's allselectablevalues equal custom element's allselectablevalues within custom element? or there another, better way of achieving it, while still maintaining two-way databound custom element?

something ?

please take note of @customelement('customelement') declarator above export class customelement line of code.

custom element view model

import {inject} 'aurelia-framework'; import {customelement} 'aurelia-framework'; import {bindable} 'aurelia-framework';  @customelement('customelement') export class customelement {     @bindable arritems } 

custom element html

<template>     <div repeat.for="item of arritems">$(item.someproperty}</div> </template> 

parent view model

export class parentviewmodel {     parentarritems = []; } 

parent html

<template>     <require from="customelement"></require>      <customelement arritems.bind="parentarritems"></customelement> </template> 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -