Reputation: 488
I'm working through the AngularJS tutorial, and understand the basics of <li ng-repeat="item in items | filter:query">
However, the out of the box implementation seems limited to just filter the list of items to the exact word or phrase entered in <input ng-model="query">
.
Example: if the query is "table cloth", the result list can include a result with this phrase, "Decorative table cloth", but won't include "Decorative cloth for table" because the filter is just a continuous search string.
I know there's the ability to add custom filters, but at first glance it seems like those are mainly transforms.
Is there any way to add a custom filter so that both "Decorative cloth for table" and "Decorative table cloth" show up in the filtered result set?
Upvotes: 0
Views: 544
Reputation: 7646
In addition to Vladimir's answer, angular ui router is a commonly used routing library that provides more features than angular's default route provider.
There's a section about passing parameters here https://github.com/angular-ui/ui-router/wiki/URL-Routing#basic-parameters
$stateProvider
.state('exampleState', {
url: "/foo/:myParameter",
templateUrl: 'foo.html',
controller: function ($stateParams) {
// If we got here from a url of /foo/42
expect($stateParams.myParameter).toBe(42);
}
})
Upvotes: 0
Reputation: 8463
Absolutely. Take a look at Angular ng-Route module
You will need to define a route:
$routeProvider.when('/add-item/:itemId', route_descriptor_object)
Here is a plunker with an example: http://plnkr.co/edit/CWq7au244DS1TiuXlu4N
Upvotes: 1