I want to select a person from the list and update the URL to get a shareable URL.
<ul>
<li ng-repeat="ctrl.persons as person" ng-click="ctrl.details(person)>{{person.name}}</li>
</ul>
<div class="details">{{ctrl.active_person.name}}</div>
in the controller
vm.persons = [{id: 1, name: "john"}, {id: 2, name: "george"}, {id: 3, name: "michael"}];
vm.details = function(person) {
$location.path('/persons/' + person.id);
vm.active_person = person;
}
I´m successfully updating the URL when I select a person from the list. te problem is that If I reload the page the selection is lost. how can I make vm.active_person = the person with the id in the url ?
notes: In this example I added an array with 3 persons but in the real code that array is coming from a service (with many many many persons)
thanks so much!