Ich arbeite an einem Projekt mit MySQL, Angular, Express und Node. Ich habe eine Liste von Objekten in einem ng-repeat und wenn ich auf ein bestimmtes Objekt klicke, möchte ich das angeklickte Objekt an eine andere Seite übergeben und die Eigenschaften des Objekts durch angular anzeigen. HierÜbergabe des Objekts in ng-repeat an eine andere Seite, um den Inhalt anzuzeigen
ist der Code:
HTML:
<div class = "panel panel-info" ng-repeat="job in job">
<div class = "panel-heading clickable">
<h1 class = "panel-title">{{job.title}}</h1>
<span class = "pull-right"><i class = "glyphicon glyphicon-minus"></i></span>
</div>
<div class = "panel-body">
<!--This will soon be the place where the Students information is placed by NodeJS-->
<!--<p style = "text-decoration: underline"> Job Title <p>-->
<p> {{job.description}} </p>
<p> {{job.first_name}} {{job.last_name}}</p>
<p> {{job.location}} </p>
<br>
<div class="form-group">
<div class=" col-sm-15">
<button onclick="location.href='jobPage.html';" type="submit" class="btn btn-default btn-block">Apply</button>
</div>
</div>
</div>
</div>
Controller:
soopControllers.controller("landingController",
function ($scope, $http){
$scope.formData = {};
$http.get('/api/jobLanding')
.success(function(data){
$scope.job = data;
console.log(data);
})
.error(function(data){
console.log('Error: ' + data);
});
//I want this function to get the job and send it to another page
$scope.getJob = function(){
$http.post('/api/job', $scope.formData)
.success(function(data){
$scope.formData = {};
$scope.users = data;
//$location.redirect();
console.log(data);
})
.error(function(data){
console.log('Error: ' + data);
});
};
});
Ich schätze Ihre Antwort! Nur neugierig, weil ich neu in der MEAN-Stack bin, was würde die SQL-Abfrage, um den Job von der ID-Nummer zu greifen aussehen wie in dieser Route für/Job /: JobId? – mapage2
Sie sind verwirrt. Eine Route ist eine clientseitige, eckige Sache. Angular führt keine SQL-Abfragen durch. Was hinter der URL ''/api/job/{jobId} 'in Ihrem Backend steckt, ist eine SQL-Anfrage, etwa 'select * from job where id =: jobId'. –
ja, das habe ich gemeint habe einfach die falsche Terminologie benutzt, ich werde es testen – mapage2