カテゴリ配列があります。より多くの製品があります。 カテゴリページにショーカテゴリが必要です。 カテゴリをクリックすると、商品ページをリダイレクトして必要な商品を表示する必要があります。 製品をクリックすると、product_detailsページをリダイレクトし、必要な製品の詳細を表示する必要があります。Json配列の詳細は、イオン性のanglejsの3ページに表示されます
カテゴリカテゴリページに移動し、カテゴリーをクリックすると商品ページが表示されます。しかし、私は製品を見ることができません。 また、これらのコントローラのエラーと、「product_details.html」と「product.html」ページの作成方法についても説明します。
- カテゴリページ:term_id、名前
- 製品ページ:POST_TITLE、ID
- 製品詳細ページ:POST_TITLE、post_date、post_author、ID
私はこのように示さなければなりません
categorylist-product.json
{
"category": [{
"term_id": "10",
"name": "Arden Grange",
"slug": "arden-grange",
"products": [{
"ID": "47",
"post_title": "Arden Grange, Premium",
"post_date": "2015-10-20 16:13:04",
"post_author": "5"
}, {
"ID": "50",
"post_title": "Arden Grange Puppy\/Junior Large Breed",
"post_date": "2015-10-21 04:56:23",
"post_author": "5"
}, {
"ID": "53",
"post_title": "Arden Grange Weaning\/Puppy",
"post_date": "2015-10-22 12:52:35",
"post_author": "5"
}]
}, {
"term_id": "8",
"name": "Menu 1",
"slug": "menu-1",
"products": [{
"ID": "38",
"post_title": "Home",
"post_date": "2015-10-20 10:43:44",
"post_author": "1"
}, {
"ID": "30",
"post_title": "",
"post_date": "2015-10-20 10:13:56",
"post_author": "1"
}, {
"ID": "31",
"post_title": "",
"post_date": "2015-10-20 10:13:57",
"post_author": "1"
}]
}]
}
CategoryController.js
app.controller('CategoryController', ['$scope','category', function($scope, category) {
category.success(function(data) {
$scope.userslists = data;
});
}]);
ProductController.js
app.controller('ProductController', ['$scope', '$routeParams', 'category', function($scope, $routeParams, category,products) {
category.success(function(data) {
$scope.users = data.category[$routeParams.id];
});
}]);
app.js
var app = angular.module('LookApp', ['ionic','ngCordova','ngRoute']);
app.config(function($stateProvider, $urlRouterProvider,$routeProvider) {
$routeProvider
.when('/', {
controller: 'CategoryController',
templateUrl: 'views/category.html'
})
.when('/:id', {
controller: 'ProductController',
templateUrl: 'views/users.html'
})
.when('/login/:friendId', {
controller: 'LoginController',
templateUrl: 'views/login.html'
})
.otherwise({
redirectTo: '/'
});
category.js(サービスファイル)
app.factory('category', ['$http', function($http) {
return $http.get('http://localhost/youtubewebservice/shop-categorylist-product.php')
.success(function(data) {
return data;
})
.error(function(err) {
return err;
});
}]);
あなたは、私がこのようなデータ配置する必要があり – Atula
カテゴリ、製品および詳細ページに* * userslistsを配置する必要があります。 「カテゴリページ:term_id、名前を」。 "商品ページ:post_title、ID" "製品詳細ページ:post_title、post_date、post_author、ID" – moni123
すべてのデータまたはその特定のterm_idの詳細のみを他のページに表示しますか? – Atula