Skip to content

Tabarray tabs do not load as promised #117

@rhalff

Description

@rhalff

When the data is loaded async the tabs will not update.

I've created an example overhere: http://plnkr.co/GFCCJ3XLB6FscPhrF7NW
(Also note clicking new, will reveal the second item)

angular.module('test', ['schemaForm']).controller('TestCtrl', function($scope, $q) {

  function asyncLoad(data) {
    var deferred = $q.defer();

    setTimeout(function() {
      deferred.resolve(data);
    }, 0);

    return deferred.promise;
  }

  var modelData = {
    names: [{
      name: 'me',
      title: 'Me'
    }, {
      name: 'hi',
      title: 'Hi'
    }]
  };


  // without a promise the tabs are correct
  // $scope.modelData = modelData;   

  // somehow the tabs are not loaded
  asyncLoad(modelData).then(function(data) {
    $scope.modelData = data;
  });


  $scope.schema = {
    "type": "object",
    "properties": {
      "names": {
        "type": "array",
        "items": {
          "type": "object",
          "title": "subform",
          "properties": {
            "name": {
              "type": "string"
            },
            "title": {
              "type": "string"
            }
          }
        }
      }
    }
  };

  $scope.form = [{
    key: "names",
    type: "tabarray",
    'title': 'value.title || value.name || "Property " + ($index + 1)',
    add: "New",
    style: {
      remove: "btn-danger"
    },
  }];
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions