Skip to content

Instantly share code, notes, and snippets.

@leondmello
Last active October 4, 2018 00:29
Show Gist options
  • Save leondmello/1934386ad97e960cac37b36cf0068847 to your computer and use it in GitHub Desktop.
Save leondmello/1934386ad97e960cac37b36cf0068847 to your computer and use it in GitHub Desktop.
OneWay CP issue
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
import { oneWay, equal } from '@ember/object/computed';
export default Ember.Controller.extend({
customRoutingType: oneWay('model.customRoutingType'),
isFixedRouted: equal('customRoutingType', 'fixed').volatile().readOnly(),
isDynamicRouted: equal('customRoutingType', 'dynamic').volatile().readOnly()
});
import EmberRouter from '@ember/routing/router';
import config from './config/environment';
const Router = EmberRouter.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('my-route')
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return {
customRoutingType: 'fixed'
};
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{{#radio-button value='fixed'
radioClass='clickable'
groupValue=customRoutingType}}
<span>Fixed</span>
{{/radio-button}}
{{#radio-button value='dynamic'
radioClass='clickable'
groupValue=customRoutingType}}
<span>Dynamic</span>
{{/radio-button}}
<br/>
Custom Routing Type: {{customRoutingType}}<br/>
Fixed: {{isFixedRouted}}<br/>
Dynamic: {{isDynamicRouted}}
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "2.18.2",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-radio-button": "1.2.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment