我在这个应用程序中使用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('/: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) {
});
}]);