I am working on a single page app using dynamic routing. I get my bookid from the URL as below
myApp.controller('BookCtrl', function($scope,$routeParams) {
$scope.mybookid=$routeParams.bookurl;
});
Here is my data
var bookdata = {
"records": [
{
"seriesid": "SpectrumSeries",
"name": "White Curse",
"bookid": "WhiteCurse",
"image": "book1",
}
...
]};
In the above controller, how to I filter out an object that has bookid that equals to $scope.mybookid? I know I can do this by ng-repeat and filter but is there a more efficient way?
bookidunique inrecords?var bookdata = { "records": { "WhiteCurse" : { "seriesid": "SpectrumSeries", "name": "White Curse", "bookid": "WhiteCurse", "image": "book1", }and thenrecords[$scope.mybookid]recordsto object, and then all work, in my sample - records is object, not an array