Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow import of exported module items into aurelia template, to allow access to static methods, static variables, enums, type definitions, etc. #743

Closed
TheNavigateur opened this issue Mar 22, 2017 · 3 comments

Comments

@TheNavigateur
Copy link

@TheNavigateur TheNavigateur commented Mar 22, 2017

I'm submitting a feature request

Something like

equivalent of

import {App, SomeEnum} from "../app";

<require def="App, SomeEnum" from="../app"/>

<some-element
    some-enum-value.bind="SomeEnum.EnumValue1"
    >
    ${App.messagesById[messageId].messageToShow}
</some-element>

etc.

  • What is the motivation / use case for changing the behavior?

Aurelia seems incomplete unless this is provided.

@EisenbergEffect
Copy link
Member

@EisenbergEffect EisenbergEffect commented Mar 23, 2017

It can be done already, though not automatically. You would use view engine hooks to declare what should be attached to the override binding context. Then when you imported that module it would make available the items you wanted.

Loading

@EisenbergEffect
Copy link
Member

@EisenbergEffect EisenbergEffect commented Mar 23, 2017

Here's an example:

resources/data/countries.js

import {viewEngineHooks} from 'aurelia-templating';

let countries = [
  { abbreviation: "AF", name: "Afghanistan" },
  { abbreviation: "AL", name: "Albania" },
  { abbreviation: "DZ", name: "Algeria" },
  ...
];

@viewEngineHooks()
export class CountryBinder {
  beforeBind(view) {
    view.overrideContext.countries = countries;
  }
}

view.html

<template class="user-detail" bindable="controller"> 
  <require from="resources/data/countries"></require>

  <select class="form-control">
    <option value="" selected="selected">(please select a country)</option>
    <option repeat.for="country of countries" value.bind="country.abbreviation">${country.name}</option>
  </select>
</template>

Loading

@Alexander-Taran
Copy link
Member

@Alexander-Taran Alexander-Taran commented Mar 19, 2018

async triageQuestion(id) =>{
 respondSameDay()
 let response = await getResponseFromOP( { timeout : Year} )
 if(!response) {
    closeQuestion(id,randomReason())
 }
}

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants