单击类别列表,使用angularjs中的类别ID获取产品 [英] Click on the category list and get products using category id in angularjs
问题描述
我在这个应用程序中使用Intelxdk。这是一个移动应用程序。
我的类别列表将显示,在点击之后,我必须重定向产品页面,当我点击我可以获得的类别时像这样的一些错误。 无法找到变量:$ state;
CategoryController.js
app.controller(' CategoryController',[' $ scope',' getServices',' JSONDataService' , function ($ scope,getServices,JSONDataService){
var url = http://look4what.biz/mobile/shop-category.php';
$ scope.getId = function (termid){
JSONDataService.addTansferData(termid);
$ state.go(' /:id');
}
getServices.sendRequest (url)
.success( function (data,status,headers,config){
$ scope.userslists = data;
})
.error( function (data,status,headers,config){
});
}]);
app.js
var app = angular.module(' LookApp',[' ionic',' ngCordova',' ngRoute',' paymentCtrls' 跨度>]);
app.config( function ($ stateProvider,$ urlRouterProvider,$ routeProvider){
$ routeProvider
.when(' /',{
controller:' CategoryController',
templateUrl:' views / category.html'
})
.when(' < span class =code-string> /:id',{
controller:' ProductController',
templateUrl:' views / users.html'
})
.when(' / login /:friendId' ,{
controller:' LoginController',
templateUrl:' views / login.html'
})
.otherwise({
redirectTo:' /'
}) ;
});
ProductController.js
app.controller(' ProductController',[' $ scope',' $ routeParams',' category ',' JSONDataService',' getServices', function ($ scope,$ routeParams,category,JSONDataService,getServices){
$ scope.newData = JSONDataService.getTansferData();
term_id = + $ scope.newData;
var url = http: // look4wha t.biz/mobile/id-get-detail.php?term_id =+ termid;
getServices.sendRequest(url)
.success( function (数据,状态,标题,配置){
$ scope.userslists = data;
})
.error( function (data,status,headers,config){
});
}]);
我尝试过:
我在这个应用程序中使用Intelxdk。这是一个移动应用程序。
我的类别列表将显示,在点击之后,我必须重定向产品页面,当我点击我可以获得的类别时像这样的一些错误。 无法找到变量:$ state;
我必须知道如何为$ stateProvider创建app.js文件。
州;
CategoryController.js
app.controller(' CategoryController ',['
scope', ' getServices',' JSONDataService', function (
scope,getServices,JSONDataService){
var url = ' http:// look4what。 BIZ /移动/店铺category.php'跨度>;
I am using Intelxdk for this application. This is a mobile application.
My categorylist will show, after that click on that, I have to redirect the product page, When I click on the category I can get some error like this. "Can't find variable: $state;
CategoryController.js
app.controller('CategoryController', ['$scope','getServices','JSONDataService', function($scope,getServices,JSONDataService) {
var url = 'http://look4what.biz/mobile/shop-category.php';
$scope.getId = function(termid){
JSONDataService.addTansferData(termid);
$state.go('/:id');
}
getServices.sendRequest(url)
.success(function(data, status, headers, config) {
$scope.userslists = data;
})
.error(function(data, status, headers, config) {
});
}]);
app.js
var app = angular.module('LookApp', ['ionic','ngCordova','ngRoute','paymentCtrls']);
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: '/'
});
});
ProductController.js
app.controller('ProductController', ['$scope', '$routeParams', 'category','JSONDataService','getServices', function($scope, $routeParams, category,JSONDataService,getServices) {
$scope.newData = JSONDataService.getTansferData();
term_id="+$scope.newData;
var url = "http://look4what.biz/mobile/id-get-detail.php?term_id="+termid;
getServices.sendRequest(url)
.success(function(data, status, headers, config) {
$scope.userslists = data;
})
.error(function(data, status, headers, config) {
});
}]);
What I have tried:
I am using Intelxdk for this application. This is a mobile application.
My categorylist will show, after that click on that, I have to redirect the product page, When I click on the category I can get some error like this. "Can't find variable: $state;
I have to know how to create app.js file for for the $stateProvider also.
state;
CategoryController.js
app.controller('CategoryController', ['
scope','getServices','JSONDataService', function(
scope,getServices,JSONDataService) { var url = 'http://look4what.biz/mobile/shop-category.php';
这篇关于单击类别列表,使用angularjs中的类别ID获取产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!