angularjsionic-frameworkbackand

Archive Master detail concept with different http requests ionic


How can i archive a master detail concept with different http requests?

I have a category list which has one or more children. Then i have a detail-view which should show only the content from the table which is related the parent element.

What i have now is this:

    .controller('CatsCtrl', function($scope $http) {
          $scope.goToDetail = function(id) {
              $state.go("detail")
              $scope.update(id);

            }

            $http.get(Backand.getApiUrl() + '/1/objects/Card')
            .then(function(response) {
                $scope.content = response.data.data;
            });

})

    .controller('DetailCtrl', function($scope $http) {
        $http.get(Backand.getApiUrl() + '/1/objects/Card')
        .then(function(response) {
            $scope.content = response.data.data;
        });
      })

HTML

<div ng-repeat="cat in content" class="animated lightSpeedIn">
      <a href="#/details/{{cat.id}}" nav-transition="none"><div ng-style="{'background': 'url(' + cat.catBgUrl + ')','background-repeat': 'no-repeat','background-size': '100% 100%','display': 'block','width': '100%','height': '25vh' }" class="bgcat center">
        <div class="inner">
          <h1>{{cat.catName}}</h1>
          <h4>{{cat.catSubtitle}}</h4>
          <img src="img/home/open.png" alt="">
        </div>
      </div></a>
    </div>

Routes

.state('details', {
      url: '/details/:id',
      templateUrl: 'templates/detail.html',
      controller: "DetailCtrl",
      cache: false
    })
.state('cats', {
      url: '/cats',
      templateUrl: 'templates/cats.html',
      controller: "CatsCtrl",
      cache: false
    })

I'm on this since 12 hours an don't make any progress. I use backand.com for the data. Can you share a link or help me a little how i could archive this with 3 different http requests?

Any help much appreciated!


Solution

  • You can archive a parent with its children with 1 $http call pls see here

    When retrieving the list of "master" objects, Backand Fails to retrieve "slave" objects

    adding related data to backand api