Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70429

Detail View

$
0
0

@Giregar wrote:

Hey guys,
I need some help with a detail view.
I've got a list of items and want to see a detail view after clicking them.

Here's my code:
controller.js

    app.controller('SuggestionCtrl', ['$scope', 'suggestionService', '$state', function($scope, suggestionService, $state){
	$scope.suggestionId = $state.params.suggestionId;

	//Lädt alle Vorschläge
	function getSuggestionDetail(suggestionId) {
    suggestionService.getItem(suggestionId)
    .success(function (suggestion) {
      $scope.suggestion = suggestion;
    });
  };
}]);

service.js

    app.service('suggestionService', ['$http', function($http) {

	var baseUrl = 'path_to_php_file';

	this.getItems = function () {
    return $http.get(baseUrl);
  };

  this.getItem = function (id) {
    return $http.get(baseUrl + '?id=' + id);
  };
}]);

detail.html

    <ion-view view-title="Details">

  <ion-content>
    <ion-list>
      <ion-item ng-repeat="detail in suggestion | filter: {id:suggestionId}">
        <img ng-src="{{ detail.titelbildUrl }}" class="full-width">
        <h2>{{ detail.titel }}</h2>
        <p>{{ detail.beschreibung }}</p>
      </ion-item>
    </ion-list>  
  </ion-content>

</ion-view>

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 70429

Trending Articles