Can angularjs routes have optional parameter values?

前端 未结 4 1014
清酒与你
清酒与你 2020-11-28 05:37

Can I set a route with optional params (same template and controller, but some params should be ignored if they don\'t exist?

So instead of writing the following two

4条回答
  •  感情败类
    2020-11-28 06:00

    Actually I think OZ_ may be somewhat correct.

    If you have the route '/users/:userId' and navigate to '/users/' (note the trailing /), $routeParams in your controller should be an object containing userId: "" in 1.1.5. So no the paramater userId isn't completely ignored, but I think it's the best you're going to get.

提交回复
热议问题