Search code examples
javascriptwakanda

Item collection from server method


Using the WakandaManager service in Quickstart gets a collection of items named 'tasks' that are listed on the client using the angular directive: <li ng-repeat="task in tasks">.

I have replaced the given code (below);

ds.Item.$all().$promise.then(function(event) {  
    $scope.tasks = event.result;  



ds.Item.getAll_items().$promise.then(function(event) {
    $scope.tasks = event.result;
    $scope.items = $wakanda.$transform.$objectToCollection(event.result);
});

The client html {{tasks.length}} gets the correct value, however; neither <li ng-repeat="task in tasks"> or <li ng-repeat="item in items"> displays the listed entities.

What is the correct syntax to display the entity collection returned by the server method?


Solution

  • You directly use $wakanda variable but it's not defined at any place.

    $wakanda is available through WakandaManager.

    So, your call to $transform method should look like this:

    ds.Item.getAll_items().$promise.then(function(event) {
        $scope.tasks = event.result;
        $scope.items = WakandaManager.$wakanda.$transform.$objectToCollection(event.result);
    });