When clicking on a link, I can pass data to another page:
<div ng-repeat="app in apps | filter:{Name: searchText}" class="slide">
<a href="#/app/{{app.Name}}">{{app.Name}} {{app.Version}}</a>
</div>
When the new page comes up, I see the app's name:
This is the markup to display the name:
<p>{{appName}}</p>
However, if I want to pass the ID, like this:
<div ng-repeat="app in apps | filter:{Name: searchText}" class="slide">
<a href="#/app/{{app.Id}}">{{app.Name}} {{app.Version}}</a>
</div>
That doesn't work. When I click on the ID, nothing happens in the browser. There is no error in the F12 tools console window. And Fiddler shows no activity. I think it's because the ID has a slash in it (this is a RavenDB convention). This is what I see when I hover over the link:
Notice the last slash. I think that's messing things up.
So I tried a stackoverflow solution to escape the slash. Now when I hover, I see this:
I thought that would have done it, but I'm back to the same behavior: nothing happens when I click on it. Nothing in Fiddler either. What am I missing? (If I change the markup to pass the Name property again, things work. So the wiring is good.)
Edit
I just realized that it's not that nothing is happening. My route provider is kicking in and taking me back to the same page that I'm already on:
$routeProvider.otherwise({ redirectTo: '/apps' });
And this is the entire routing config:
app.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/apps', { templateUrl: 'partials/apps.html', controller: 'appsController' });
$routeProvider.when('/servers', { templateUrl: 'partials/servers.html', controller: 'serversController' });
$routeProvider.when('/app/:appId?', { templateUrl: 'partials/app.html', controller: 'appController' });
$routeProvider.otherwise({ redirectTo: '/apps' });
}]);
Workaround
Setting a route like this allows me to hit the right page. The only issue is that I need to prefix the number part of the ID (on the receiving page) with the literal "applications/". I guess I can do that.
$routeProvider.when('/app/applications/:appId?', { templateUrl: 'partials/app.html', controller: 'appController' });
For completeness, this is what I had to do in the receiving controller:
.controller('appController', function ($scope, $routeParams) {
$scope.appId = "applications/" + $routeParams.appId;
})