bosun.org@v0.0.0-20210513094433-e25bc3e69a1f/cmd/bosun/web/static/js/angular-route.d.ts (about)

     1  // Type definitions for Angular JS 1.3 (ngRoute module)
     2  // Project: http://angularjs.org
     3  // Definitions by: Jonathan Park <https://github.com/park9140>
     4  // Definitions: https://github.com/borisyankov/DefinitelyTyped
     5  
     6  /// <reference path="angular.d.ts" />
     7  
     8  declare module "angular-route" {
     9      var _: string;
    10      export = _;
    11  }
    12  
    13  ///////////////////////////////////////////////////////////////////////////////
    14  // ngRoute module (angular-route.js)
    15  ///////////////////////////////////////////////////////////////////////////////
    16  declare module angular.route {
    17  
    18      ///////////////////////////////////////////////////////////////////////////
    19      // RouteParamsService
    20      // see http://docs.angularjs.org/api/ngRoute.$routeParams
    21      ///////////////////////////////////////////////////////////////////////////
    22      interface IRouteParamsService {
    23          [key: string]: any;
    24      }
    25  
    26      ///////////////////////////////////////////////////////////////////////////
    27      // RouteService
    28      // see http://docs.angularjs.org/api/ngRoute.$route
    29      // see http://docs.angularjs.org/api/ngRoute.$routeProvider
    30      ///////////////////////////////////////////////////////////////////////////
    31      interface IRouteService {
    32          reload(): void;
    33          routes: any;
    34  
    35          // May not always be available. For instance, current will not be available
    36          // to a controller that was not initialized as a result of a route maching.
    37          current?: ICurrentRoute;
    38          
    39          /**
    40           * Causes $route service to update the current URL, replacing current route parameters with those specified in newParams.
    41           * Provided property names that match the route's path segment definitions will be interpolated into the
    42           * location's path, while remaining properties will be treated as query params.
    43           *
    44           * @param newParams Object.<string, string> mapping of URL parameter names to values
    45           */
    46          updateParams(newParams:{[key:string]:string}): void;
    47      }
    48  
    49      type InlineAnnotatedFunction = Function|Array<string|Function>
    50  
    51      /**
    52       * see http://docs.angularjs.org/api/ngRoute/provider/$routeProvider#when for API documentation
    53       */
    54      interface IRoute {
    55          /**
    56           * {(string|function()=}
    57           * Controller fn that should be associated with newly created scope or the name of a registered controller if passed as a string.
    58           */
    59          controller?: string|InlineAnnotatedFunction;
    60          /**
    61           * A controller alias name. If present the controller will be published to scope under the controllerAs name.
    62           */
    63          controllerAs?: string;
    64          /**
    65           * Undocumented?
    66           */
    67          name?: string;
    68          /**
    69           * {string=|function()=}
    70           * Html template as a string or a function that returns an html template as a string which should be used by ngView or ngInclude directives. This property takes precedence over templateUrl.
    71           *
    72           * If template is a function, it will be called with the following parameters:
    73           *
    74           * {Array.<Object>} - route parameters extracted from the current $location.path() by applying the current route
    75           */
    76          template?: string|{($routeParams?: angular.route.IRouteParamsService) : string;}
    77          /**
    78           * {string=|function()=}
    79           * Path or function that returns a path to an html template that should be used by ngView.
    80           *
    81           * If templateUrl is a function, it will be called with the following parameters:
    82           *
    83           * {Array.<Object>} - route parameters extracted from the current $location.path() by applying the current route
    84           */
    85          templateUrl?: string|{ ($routeParams?: angular.route.IRouteParamsService): string; }
    86          /**
    87           * {Object.<string, function>=} - An optional map of dependencies which should be injected into the controller. If any of these dependencies are promises, the router will wait for them all to be resolved or one to be rejected before the controller is instantiated. If all the promises are resolved successfully, the values of the resolved promises are injected and $routeChangeSuccess event is fired. If any of the promises are rejected the $routeChangeError event is fired. The map object is:
    88           *
    89           * - key - {string}: a name of a dependency to be injected into the controller.
    90           * - factory - {string|function}: If string then it is an alias for a service. Otherwise if function, then it is injected and the return value is treated as the dependency. If the result is a promise, it is resolved before its value is injected into the controller. Be aware that ngRoute.$routeParams will still refer to the previous route within these resolve functions. Use $route.current.params to access the new route parameters, instead.
    91           */
    92          resolve?: {[key: string]: any};
    93          /**
    94           * {(string|function())=}
    95           * Value to update $location path with and trigger route redirection.
    96           *
    97           * If redirectTo is a function, it will be called with the following parameters:
    98           *
    99           * - {Object.<string>} - route parameters extracted from the current $location.path() by applying the current route templateUrl.
   100           * - {string} - current $location.path()
   101           * - {Object} - current $location.search()
   102           * - The custom redirectTo function is expected to return a string which will be used to update $location.path() and $location.search().
   103           */
   104          redirectTo?: string|{($routeParams?: angular.route.IRouteParamsService, $locationPath?: string, $locationSearch?: any) : string};
   105          /**
   106           * Reload route when only $location.search() or $location.hash() changes.
   107           *
   108           * This option defaults to true. If the option is set to false and url in the browser changes, then $routeUpdate event is broadcasted on the root scope.
   109           */
   110          reloadOnSearch?: boolean;
   111          /**
   112           * Match routes without being case sensitive
   113           *
   114           * This option defaults to false. If the option is set to true, then the particular route can be matched without being case sensitive
   115           */
   116          caseInsensitiveMatch?: boolean;
   117      }
   118  
   119      // see http://docs.angularjs.org/api/ng.$route#current
   120      interface ICurrentRoute extends IRoute {
   121          locals: {
   122              [index: string]: any;
   123              $scope: IScope;
   124              $template: string;
   125          };
   126  
   127          params: any;
   128          loadedTemplateUrl: string;
   129      }
   130  
   131      interface IRouteProvider extends IServiceProvider {
   132  		/**
   133           * Match routes without being case sensitive
   134           *
   135           * This option defaults to false. If the option is set to true, then the particular route can be matched without being case sensitive
   136           */
   137          caseInsensitiveMatch?: boolean;
   138          /**
   139           * Sets route definition that will be used on route change when no other route definition is matched.
   140           *
   141           * @params Mapping information to be assigned to $route.current.
   142           */
   143          otherwise(params: IRoute): IRouteProvider;
   144          /**
   145           * Adds a new route definition to the $route service.
   146           *
   147           * @param path Route path (matched against $location.path). If $location.path contains redundant trailing slash or is missing one, the route will still match and the $location.path will be updated to add or drop the trailing slash to exactly match the route definition.
   148           *
   149           * - path can contain named groups starting with a colon: e.g. :name. All characters up to the next slash are matched and stored in $routeParams under the given name when the route matches.
   150           * - path can contain named groups starting with a colon and ending with a star: e.g.:name*. All characters are eagerly stored in $routeParams under the given name when the route matches.
   151           * - path can contain optional named groups with a question mark: e.g.:name?.
   152           *
   153           * For example, routes like /color/:color/largecode/:largecode*\/edit will match /color/brown/largecode/code/with/slashes/edit and extract: color: brown and largecode: code/with/slashes.
   154           *
   155           * @param route Mapping information to be assigned to $route.current on route match.
   156           */
   157          when(path: string, route: IRoute): IRouteProvider;
   158      }
   159  }