Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
  <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/2.1.0/normalize.css">
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
  <script src="http://builds.emberjs.com/tags/v2.1.1/ember.debug.js"></script>
  <script src="http://builds.emberjs.com/tags/v2.1.1/ember-template-compiler.js"></script>
</head>
<body>
  <div id='app'></div>
  <pre id="logs"></pre>
  
  <script type="text/x-handlebars">
    <h2>rwjblue's Ember JSBins</h2>
    
    Normal:
    {{link-to 'normal foo' 'foo' 'first' 'second'}} |
    {{link-to 'normal bar' 'bar' 'first' 'second' 'third'}}  
    <hr/>
    Dynamic: {{#link-to params=dynamicLinkParams}}Dynamic Link{{/link-to}}
    <hr/>
    <button {{action 'switchLink'}}>Switch Dynamic Link</button>
  </script>
  
</body>
</html>
 
/* Put your CSS here */
html, body {
    margin: 20px;
}
 
var App = Ember.Application.create({
  rootElement: '#app',
  LOG_RESOLVER: true
});
App.Router.map(function() {
  this.route('foo', { path: 'foo/:some/:thing'});
  this.route('bar', {path: 'bar/:some/:thing/:else'});
});
App.ApplicationRoute = Ember.Route.extend({
  actions: {
    error: function(error) {
      log(error.message);
    }
  }  
});
App.ApplicationController = Ember.Controller.extend({
  init() {
    this.dynamicLinkParams = [
      'foo',
      'one',
      'two'
    ];
  },
  actions: {
    switchLink() {
      if (this.get('dynamicLinkParams')[0] === 'foo') {
        this.set('dynamicLinkParams', [
          'bar',
          'one',
          'two',
          'three'
        ]);
      } else {
        this.set('dynamicLinkParams', [
          'foo',
          'one',
          'two'
        ]);        
      }
    }
  }
})
function log() {
  var msg = [].slice.call(arguments).join(' ');
  logs.insertBefore(document.createTextNode("\n" + msg), logs.firstChild);
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
rwjbluepro
0viewers