dimanche 25 octobre 2015

I have tried to call a data through JSON using EMBER . But it's not coming properly

          //21_JSONcall.html 
          <!DOCTYPE html>
            <html>
            <head>
              <meta charset="utf-8">
              <title>Ember Starter Kit</title>
              <link rel="stylesheet" href="css/normalize.css">
              <link rel="stylesheet" href="css/style.css">
            </head>
            <body>
              <script type="text/x-handlebars"> 
                <h2>Welcome to Ember Table</h2>
            <h2>Definig Models</h2>
            {{outlet}}
              </script>

            <script type="text/x-handlebars" id="index">
            <ul>
                {{#each item in model}}
                  <li>{{item.name}} :{{item.designation}} : {{item.salary}} :{{item.joining_date}} :{{item.office}} :{{item.extension}}</li>

                {{/each}}

             </ul>    
            </script>



    //sids.json
    {  
       "sids":[  
          {  
             "id": 1,
             "name":"Honey jain",
             "designation":"Software Engineer",
             "salary":"$1000",
             "joining_date":"2015/05/15",
             "office":"Mumbai",
             "extension":"5051"
          },
          {  
          "id": 2,
             "name":"Saurabh jain",
             "designation":"Software Engineer",
             "salary":"$1001",
             "joining_date":"2015/05/15",
             "office":"Mumbai",
             "extension":"5052"
          },
          {  
          "id": 3,
             "name":"Yash jain",
             "designation":"Software Engineer",
             "salary":"$1002",
             "joining_date":"2015/05/15",
             "office":"Mumbai",
             "extension":"5053"
          }

       ]
    }


    //21_JSONcall.js

    App = Ember.Application.create();



    App.SidAdapter=DS.RESTAdapter.extend({

        namespace: "embertest/json", 

            suffix: '.json',

          pathForType: function(type) {
            return this._super(type) + this.get('suffix');
          },


    });


    App.Sid =DS.Model.extend({
        name: DS.attr('string'),
        designation: DS.attr('string'),
        salary: DS.attr('string'),
        joining_date: DS.attr('string'),
        office: DS.attr('string'),
        extension: DS.attr('string')

    });


    App.IndexRoute = Ember.Route.extend({
          model: function() {

            return this.store.find('sid');
          }
    });

//My required output is in form of table but i'm not able to get the output properly . Console is not showing anytype of error . Please help if i have done anything wrong while writing this code . I'm new to emberjs. Thanks

//OUTPUT :

Welcome to Ember.js
Definig Models

    Honey jain
    Saurabh jain
    Yash jain




Aucun commentaire:

Enregistrer un commentaire