Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

Static JSON binding to a Page

$
0
0

Hi Team

 

We have a JSON file and I'm trying to bind it to my Page. But we don't see the values ,please correct me if some binding is missing here ?

 

 

createContent: function(controller){


var oModel = new sap.ui.model.json.JSONModel();

oModel.loadData("questions.json");

 

vardata=oModel.getData();  // Don't see any data during debugging !!

 

var page = new sap.m.Page({


      title : "Page2",

    value : "{/questions/name}",

navButtonTap : [ controller.onClick, controller ],


content: [

new sap.m.VBox(

          items: [

new sap.m.Text({


                        id : Question',

                         text: "{/questions/name/1}",

                  

                    }).addStyleClass('Question'),



  

    ...............

 

My Json will be like below  (a very simple Quiz sample where I would like to present on the UI)

 

{


    "questions": [


        {


            "name": "Can you identify this color?",


            "description": "#ea4c89",


            "answers": [


                {


                    "name": "Dribbble",


                    "description": "dribbble.png",


                    "weight": 1


                },


                {


                    "name": "Amazon",


                    "description": "amazon.png",


                    "weight": 0


                },


                {


                    "name": "Apple",


                    "description": "apple.png",


                    "weight": 0


                }


            ]


        },



Viewing all articles
Browse latest Browse all 6178

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>