Boas malta,
Eu estou a tentar criar um simples parâmetro no meu route no angularjs. O que eu pretendo é que a minha página job sempre que carrego num artigo abra noutra página a informação desse artigo. Eu consigo buscar o ID mas a informação não me aperece nada. Diz que o id não está definido.
O meu código é o seguinte:
app.js
.when("/job" , {
templateUrl: "app/components/job/views/job.html",
controller: "job"
})
.when("/job/:jobId" , {
templateUrl: "app/components/job/views/jobdetail.html",
controller: "job_detail"
})
job.js
$scope.products = [];
$http.get('app/components/job/controller/teste.json').success(function (resource) {
$scope.products = resource;
});
$scope.jobId = $routeParams;
job_detail.js
app.controller("job_detail", ["$scope", "$http", "$location", "$route","$rootScope", "$routeParams", function($scope, $http, $location, $route, $rootScope, $routeParams) {
$scope.products = [];
$http.get('app/components/job/controller/teste.json').success(function (resource) {
$scope.products = resource;
});
$scope.jobId = $routeParams.jobId;
console.log($scope.jobId);
$scope.params = $scope.jobId.get(id);
}]);
html job:
<article dir-paginate="product in filteredJobs | filter:searchTerm | orderBy: sorting.order:sorting.direction | itemsPerPage:5" id="{{product.id}}" class="productlist product col-sm-12">
<div class="inner-content">
<div class="clearfix">
<div class="col-md-8 col-sm-8 col-xs-8">
<h4 class="productname" name="{{product.Categoria}}"><a data-ng-href="#/job/{{product.id}}">{{product.Title}}</a></h4>
<h4 style="color: gray;"><a data-ng-href="#/empresa">{{product.Empresa}}</a></h4>
<span class="glyphicon glyphicon-map-marker" style="float:left; padding-right: 15px;"><h6 style="display: inline">{{product.Localidade}}</h6></span>
<span class="glyphicon glyphicon-time" style="float:left;"><h6 style="display: inline;">{{product.Horario}}</h6></span>
</div>
<div class="col-md-4 col-sm-4 col-xs-4">
<a class="thumb" data-id="{{product.id}}" data-ng-href="#/product/{{product.id}}">
<img ng-src="{{product.Image}}" class="img_jobs">
</a>
</div>
</div>
</div>
</article>
job_detail html:
<!-- Job Section -->
<section id="slide" class="job-section">
<article id="{{product.id}}" class="productlist product col-sm-12">
<div class="inner-content">
<div class="clearfix">
<div class="col-md-8 col-sm-8 col-xs-8">
<h4 class="productname" name="{{product.Categoria}}">{{product.Title}}</h4>
</div>
</div>
</div>
</article>
</section>