diff options
| author | Igor Minar | 2012-04-03 15:28:09 -0700 | 
|---|---|---|
| committer | Igor Minar | 2012-04-04 16:10:44 -0700 | 
| commit | 15ecc6f3668885ebc5c7130dd34e00059ddf79ae (patch) | |
| tree | ab037fbdf3df20f53e96169925367536de736ce7 /src | |
| parent | 53b2254ea70019937463d8e079e1991b3d3d1d8b (diff) | |
| download | angular.js-15ecc6f3668885ebc5c7130dd34e00059ddf79ae.tar.bz2 | |
feat($route): allow chaining of whens and otherwise
Previously one had to write:
$routeProvider.when('/foo', {...});
$routeProvider.when('/bar', {...});
$routeProvider.otherwise({...});
After this change it's just:
$routeProvider.
    when('/foo', {...}).
    when('/bar', {...}).
    otherwise({...});
Breaks #when which used to return the route definition object but now
returns self. Returning the route definition object is not very useful
so its likely that nobody ever used it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ng/route.js | 10 | 
1 files changed, 5 insertions, 5 deletions
| diff --git a/src/ng/route.js b/src/ng/route.js index 2b9d187a..864cb0ee 100644 --- a/src/ng/route.js +++ b/src/ng/route.js @@ -51,15 +51,13 @@ function $RouteProvider(){     *      If the option is set to `false` and url in the browser changes, then     *      `$routeUpdate` event is broadcasted on the root scope.     * -   * @returns {Object} route object +   * @returns {Object} self     *     * @description     * Adds a new route definition to the `$route` service.     */    this.when = function(path, route) { -    var routeDef = routes[path]; -    if (!routeDef) routeDef = routes[path] = {reloadOnSearch: true}; -    if (route) extend(routeDef, route); // TODO(im): what the heck? merge two route definitions? +    routes[path] = extend({reloadOnSearch: true}, route);      // create redirection for trailing slashes      if (path) { @@ -70,7 +68,7 @@ function $RouteProvider(){        routes[redirectPath] = {redirectTo: path};      } -    return routeDef; +    return this;    };    /** @@ -83,9 +81,11 @@ function $RouteProvider(){     * is matched.     *     * @param {Object} params Mapping information to be assigned to `$route.current`. +   * @returns {Object} self     */    this.otherwise = function(params) {      this.when(null, params); +    return this;    }; | 
