Skip to content

Instantly share code, notes, and snippets.

@jlami
Last active April 14, 2020 15:20
Show Gist options
  • Save jlami/39138ab576de35bb8b09dc8fc40ade45 to your computer and use it in GitHub Desktop.
Save jlami/39138ab576de35bb8b09dc8fc40ade45 to your computer and use it in GitHub Desktop.
ember-int-htmlattr-delay
import Controller from '@ember/controller';
import {action} from '@ember/object';
import { inject as service } from '@ember/service';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@service intl;
date = new Date();
constructor(...args) {
super(...args);
this.intl.on('localeChanged', () => {
if (this.intl.locale.includes('fr')) {
for (let i=0; i<10000; i++)
console.log('slow');
}
});
}
@action
testMe() {
console.log('action', [this.intl.locale.includes('fr') ? 'fr' : 'en']);
this.intl.setLocale([this.intl.locale.includes('fr') ? 'en' : 'fr']);
}
}
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
div.date
{
//background: blue;
display: inline-block;
}
[lang=fr] div.date {
background: red;
}
<h1>Welcome to {{this.appName}}</h1>
<br>
<br>
<div>
<div class="date">
{{format-date date}}
</div>
</div>
<button {{on 'click' this.testMe}}>Testme</button>
{{outlet}}
<br>
<br>
{
"version": "0.17.0",
"EmberENV": {
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": true
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.17.0",
"ember-template-compiler": "3.17.0",
"ember-testing": "3.17.0"
},
"addons": {
"@glimmer/component": "1.0.0",
"ember-intl": "4.3.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment