You can use bool as a type
url: '/foobar?{flag1:bool}&{flag2:bool}',
But we can even use our custom type (call it boolean ):
app.config(['$urlMatcherFactoryProvider', function($urlMatcherFactory) { $urlMatcherFactory.type('boolean', { name : 'boolean', decode: function(val) { return val == true ? true : val == "true" ? true : false }, encode: function(val) { return val ? 1 : 0; }, equals: function(a, b) { return this.is(a) && a === b; }, is: function(val) { return [true,false,0,1].indexOf(val) >= 0 }, pattern: /bool|true|0|1/ }) }]);
And the def state for url will be like this:
url: '/foobar?{flag1:boolean}&{flag2:boolean}',
and this should work:
<a ui-sref="foobar({ flag1: 0, flag2:true })"> <a ui-sref="foobar({ flag1: 1, flag2:false })">
Here is a plunker with an example
Radim Köhler
source share