Eu tenho isto:
$scope.products = [];
$http.get('app/components/job/controller/teste.json').success(function (resource) {
$scope.products = resource;
});
$scope.getIdJobs = function(getIdJobs) {
var result = $filter('filter')( $scope.products, {id:getIdJobs})[0];
console.log(result);
console.log(getIdJobs);
}
Pretendia que o meu segundo controlador conseguisse obter a variavel $scope.getIdJobs e guardar numa variável novamente. Como posso fazer isso?
app.controller("job_detail", ["$scope", "$http", "$location", "$route","$rootScope", "$routeParams", function($scope, $http, $location, $route, $rootScope, $routeParams) {
//image home
$rootScope.home = false;
//change color background in page job
$scope.isOnCertainPage = function() {
return $location.path() === "/job";
};
$http.get('app/components/job/controller/teste.json').success(function (resource) {
$scope.products = resource;
$scope.jobId = $routeParams.jobId;
//console.log($scope.jobId);
});
console.log($scope.title, $scope.localidade, $scope.products);
}]);
app.js
app.config(function($routeProvider, RestangularProvider){
$routeProvider
.when("/",{
templateUrl: "app/components/home/views/job_offers.html",
controller: "employerCtrl"
})
.when("/job" , {
templateUrl: "app/components/job/views/job.html",
controller: "job"
})
.when("/job/:jobId" , {
templateUrl: "app/components/job/views/jobdetail.html",
controller: "job_detail"
})
.otherwise({
redirectTo: '/'
});
});