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.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.3.0.js"></script>
  <script src="http://builds.emberjs.com/tags/v1.8.0/ember.js"></script>
</head>
<body>
  <script type="text/x-handlebars">
    <h2>Welcome to Ember.js</h2>
    {{outlet}}
  </script>
  <script type="text/x-handlebars" data-template-name="index">
    {{#each model }}
     {{#ifCond title Raja}}
     <div>equal to</div>
     {{else}}
     <div>not equal to</div>  
     {{/ifCond}}
     {{/each}}
     
     <button {{action "addObject"}}> add random object</button>
  </script>
</body>
</html>
 
/* Put your CSS here */
html, body {
  margin: 20px;
}
 
App = Ember.Application.create();
App.Router.map(function() {
  // put your routes here
});
App.IndexRoute = Ember.Route.extend({
  model: function() {
    return posts;
  }
});
App.IndexController = Em.ArrayController.extend({
  actions:{
    addObject:function(){
      this.get("model").pushObject({
    title: Math.floor(Math.random()*2)===0?"Raja":"something else",
    body: "James Coglan wrote a lengthy article about Promises in node.js."
});
    }
  }
  
});
var posts = [{
    title: "sample",
    body: "There are lots of à la carte software environments in this world."
}, {
    title: "Broken Promises",
    body: "James Coglan wrote a lengthy article about Promises in node.js."
},
            {
    title: "Raja",
    body: "James Coglan wrote a lengthy article about Promises in node.js."
}];
Handlebars.registerHelper('ifCond', function (v1, v2, options) {
  var _v1 = Em.get(this,v1);
  var _v2 = Em.get(this,v2);
v1 = Em.isEmpty(_v1)?v1:_v1;
  v2 = Em.isEmpty(_v2)?v2:_v2;
    if (v1 === v2) {
        return options.fn(this);
    }
    return options.inverse(this);
});
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers