title: Nativescript Pass data to view
body: <p>I am facing a problem while developing a nativescript android app.I am trying to send a POST request and from that request  I am trying to get a response.Using this response I am trying to populate a ListView. I have successfully sent the post request and got the response from server.But problem is I can not populate the listview.Here is my code-</p>
  
  <p><strong>Register.xml</strong></p>
  
  <pre><code>   &lt;Page loaded="loaded"&gt;
      &lt;StackLayout&gt;
          &lt;Image src="res://logo" stretch="none" horizontalAlignment="center"/&gt;
  
          &lt;TextField text="{{ name }}" id="name" hint="Name"  /&gt;
  
          &lt;TextField text="{{ email }}" id="email" hint="E-mail"  /&gt;
  
          &lt;TextField text="{{ password }}" secure="true" hint="Password" /&gt;
  
          &lt;Button text="Sign Up" tap="register" /&gt;
      &lt;/StackLayout&gt;
  &lt;/Page&gt;
  </code></pre>
  
  <p><strong>Register.js</strong></p>
  
  <pre><code>var dialogsModule = require("ui/dialogs");
  var frameModule = require("ui/frame");
  
  var UserViewModel = require("../../shared/view-models/user-view-model");
  var user = new UserViewModel();
  
  exports.loaded = function(args) {
      var page = args.object;
      page.bindingContext = user;
  };
  
  function completeRegistration() {
      user.register()
          .then(function() {
              dialogsModule
                  .alert("Your account was successfully created.")
                  .then(function() {
                      frameModule.topmost().navigate("views/list/list");
                  });
          }).catch(function(error) {
              console.log(error);
              dialogsModule
                  .alert({
                      message: "Unfortunately we were unable to create your account.",
                      okButtonText: "OK"
                  });
          });
  }
  
  exports.register = function() {
      completeRegistration();
  };
  </code></pre>
  
  <p><strong>User-view model.js</strong></p>
  
  <pre><code>function User(info) {
      info = info || {};
  
  
      var viewModel = new Observable({
          name: info.name || "",
          email:info.email || "",
          password: info.password || "",
      });
  
      viewModel.register = function() {
  
  
  
      return fetchModule.fetch("http://10.0.2.2:8000/user_signup", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ 
  
             name: viewModel.get("name"),
             email:viewModel.get("email"),
             password:viewModel.get("password"),
          }).then(r =&gt; { return r.json(); }).then(function (r) {
  
  
     for(var i=0;i&lt;r.length;i++){
  
         var goods={name:r[i].name}
         goodsList.push(goods);
  
  
     };
    console.log(goodsList);
  
  }, function (e) {
           console.log("Error occurred " + e);
      });
  
  
      };
  
        return viewModel;
  }
  
  function handleErrors(response) {
      if (!response.ok) {
          console.log(JSON.stringify(response));
          throw Error(response.statusText);
      }
      return response;
  }
  
  
  function pageLoaded(args) {
          var page = args.object;
          pageData.set("goodsList", goodsList);
  
          page.bindingContext = pageData;
      }
  
  module.exports = User;
  </code></pre>
  
  <p><strong>List view</strong>  </p>
  
  <pre><code>    &lt;Page loaded="pageLoaded"&gt;
      &lt;GridLayout&gt;
          &lt;ListView items="{{ goodsList }}"&gt;
              &lt;ListView.itemTemplate&gt;
                  &lt;Label text="{{ name }}" horizontalAlignment="left" verticalAlignment="center"/&gt;
              &lt;/ListView.itemTemplate&gt;
          &lt;/ListView&gt;
      &lt;/GridLayout&gt;
  &lt;/Page&gt;
  </code></pre>