Javascript 单击类别列表并使用angularjs中的类别id获取产品

Javascript 单击类别列表并使用angularjs中的类别id获取产品,javascript,php,jquery,angularjs,intel-xdk,Javascript,Php,Jquery,Angularjs,Intel Xdk,我正在使用Intelxdk进行此应用程序。这是一个移动应用程序 我的分类列表将显示,在点击之后,我必须重定向产品页面,当我点击分类时,我会得到一些类似这样的错误。“找不到变量:$state” CategoryController.js app.controller('CategoryController', ['$scope','getServices','JSONDataService', function($scope,getServices,JSONDataService) { var

我正在使用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) {

        });

}]);
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: '/'
});


});
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) {

    });

}]);

app.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) {

        });

}]);
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: '/'
});


});
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) {

    });

}]);

ProductController.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) {

        });

}]);
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: '/'
});


});
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) {

    });

}]);

CategoryController
中,您需要进行依赖项注入。像这样
app.controller('CategoryController',['$scope','getServices','JSONDataService','$state',function($scope,getServices,JSONDataService,$state)…。
现在,我可以看到这个错误无法解决来自状态的'/:id'如何修复
$state
的itRead。试试
$state.go('id',termid)
。我浏览了这个文档,但我无法修复它。请您帮助我。在
CategoryController
中,您需要进行依赖项注入。像这样
app.controller('CategoryController'、['$scope'、'getServices'、'JSONDataService'、'$state',函数($scope、getServices、JSONDataService、$state)…
现在,我可以看到此错误无法从状态“”解析“/:id”如何修复它读取
$state
。请尝试
$state.go('id',termid)
。我浏览了此文档,但无法修复它。请帮助我。