Now I need switch view by using $state.go, but I need to pass some data in it. (I perfer to pass a object) I searched on line for help, but didn't see a good answer which fit my question. Here is my code:
state('editreport', {
url: '/editreport/:reports',
templateUrl: 'submitter/editreport/editexpensesreport.html'
})
in my Ctr1:
$scope.goeditpage = function(report){
$state.go('editreport',{'reports':report});
}
when user fire goeditpage . it will take them to 'editreport' page.and in editreport page, I have another controller called 'ctr2', I try to access data like this:
controller('Ctr2',
[ '$scope','$stateParams', function($scope,$stateParams) {
$scope.lin = $stateParams.reports;
console.log($scope.lin);
} ])
but didn't work out, any idea? and another question is how to make data optional? because user may enter data or not, but it will always take them to this page.