1
我新的角度,我不明白爲什麼我的數據不是從控制器發送到另一個狀態參數我有我的控制檯「undefined」。你能幫我解決這個問題嗎?
我的控制器:
.controller('RegistreCtrl', function ($scope, $stateParams,factotransaction,$state) {
console.log("coucou");
var mytoken = sessionStorage.getItem('token');
factotransaction.send(mytoken).then(function(conf)
{
console.log(conf);
$scope.datab = conf.data;
})
$scope.operation = function(id){
$state.go('app.operation', { id: id });
$state.params.id = id;
}
})
.controller('OperationCtrl', function ($scope, $stateParams,factotransaction,$state) {
var mytoken = sessionStorage.getItem('token');
factotransaction.send(mytoken).then(function(conf){
console.log(conf);
conf.data.forEach(function(item){
console.log($state.params.id);
if($state.params.id == item.id) {
$scope.item = item;
console.log(item);
}
});
});
我app.js:
.state('app.operation', {
url: '/operation',
views: {
'menuContent': {
templateUrl: 'templates/operation.html',
controller: 'OperationCtrl'
}
}
})
;
嘗試'$ state.current.params.id',並將狀態的url更改爲'url:'/ operation /:id',' –
哇!問題是網址!把它作爲答案,然後我會驗證:) – xenurs
謝謝,但我沒有足夠的時間寫一個完整的寫得很好的問題。很高興我能夠幫助:) –