I've really done this a hundred times and it turns out to me, capable is a nonsense that I'm not seeing.
My problem is that when I do $location.path('/Miruta/'+id);
(The url is generated in this way http://localhost/mysite/WebContent/#/alta/minDetalle/2789
) when it reaches the destination URL, the $routeParams.id
comes to me as undefined, and it should be 2789
I leave the code.
//Parte del App.js
app
.config([
'$routeProvider',
'$locationProvider',
'$httpProvider',
function($routeProvider, $locationProvider, $httpProvider) {
$httpProvider.interceptors.push('sacgHttpInterceptor');
$routeProvider
.when("/alta/minDetalle/:id", {
templateUrl: "pages/altas/mindetalle.html",
controller: 'MinDetalleCtrl',
controllerAs: 'vm'
})
.otherwise({
templateUrl: "pages/home.html",
controller: "homeCtrl"
});
}]);
//Registro.js
//Llamo mi servicio de guardar
ObjectFactory.save(min).then(function(data){
console.log('Salvado!!!');
var id = data.idMinutario;
resetDropDown();
$location.path('/alta/minDetalle/'+id);
});
//Js donde redirecciono.
(function(){
'use strict';
/*
* Para mejor lectura del codigo es mejor colocarlo de esta forma (Nombre
* cotrolador, Nombre de funcion)
*/
app.controller('MinDetalleCtrl', MinDetalle);
// /* Inyecto las dependencia que va a necesitar mi funcion main */
MinutarioDetalle.$inject = ['$scope', '$rootScope', '$http', 'ObjectFactory', "$location", 'DTOptionsBuilder', '$filter', '$q', "ObjectFactoryPersistence", "$interval", '$routeParams'];
////Funcion de mi controller
function MinutarioDetalle($rootScope, $http, ObjectFactory, $location, DTOptionsBuilder, $filter, $q, ObjectFactoryPersistence, $interval, $routeParams){
///Asignamos this to vm (ViewModel) Porque amamos los VM :D
console.log("llegue bien");
console.log($routeParams.id); //undefined
var vm = this;
vm.hideToggle = true;
vm.hideToggleDocumentos = true;
vm.hideToggleAnexos = true;
vm.testCode = "Hellos World";
vm.click = clickme;
function clickme(){
alert('test');
}
}
})();
I do not know what I'm doing wrong, I think it's something of the VM
I'm trying to implement, but I honestly do not know where the error is.
Additionally, I do not see any errors in the console.