Created
February 29, 2016 22:31
-
-
Save AlexanderArmua/13d4667791d4c6a5ef02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Se pasan parametros entre controllers mediante la URL, esto no puede superar los 1023 caracteres. | |
En el BAG seria el routes.js y en el controller se toma normal. | |
*/ | |
var app = angular.module("MyApp", []); | |
app.config(function($routeProvider) { | |
$routeProvider. | |
when('/view1', { | |
templateUrl: 'view1.html', | |
controller: 'Ctrl1' | |
}). | |
when('/view2/:personId', { //Aca se le agrega :personId para que despues se pueda tomar desde el routeParams | |
templateUrl: 'view2.html', | |
controller: 'Ctrl2' | |
}); | |
}); | |
app.controller('Ctrl1', function($scope, $location) { | |
$scope.goTo2 = function(person) { | |
$location.url('/view2/' + person.id); //el $location identifica person como una variable | |
}; | |
}); | |
app.controller('Ctrl2', function($scope, $routeParams) { | |
$scope.message = 'PersonId = ' + $routeParams.personId; //routeParams tomando el valor... | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment