I have tried what was helped in: UI Router load detail page from a list page
and I encountered a problem as the code I implemented was different overall.
Here I have the config.js:
.state('app.projects', {
url: "/projects",
templateUrl: "views/projects.html",
data: { pageTitle: 'Projects' },
controller: 'ProjectCtrl'
})
.state('app.project_detail', {
url: "/project_detail",
view: {
'project_detail':{
templateUrl: 'views/project_detail.html',
controller: 'ProjectDetailCtrl'
}
},
data: { pageTitle: 'Project detail' }
})
and I have the project (MASTER) html:
<td class="project-actions">
<a ui-sref="app.project_detail/({project_id:1})" class="btn btn-white btn-sm"><i class="fa fa-folder"></i> View </a>
</td>
and the project_detail (DETAIL)
<h2> {{project_data.project_id}}</h2>
and finally the controller.js:
function ProjectCtrl($scope, $http, $timeout, $state, $stateParams) {
$http.get('../crud/projects_read.php').then(function(response){
$scope.projects = response.data;
});
};
function ProjectDetailCtrl($scope, $http, $timeout, $state, $stateParams) {
$scope.project_data = $scope.projects[$stateParams.project_id]
};
I think I have all set in proper manner, but the UI-SREF does not work and I think the data does not seem to be passed from the Project --> Project Detail in the controller.js file.
Could anyone help me? I am stuck and have been trying almost whole day with different examples (can't even count!).
Thank you in advance!