• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript core.StateRegistry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@uirouter/core.StateRegistry的典型用法代码示例。如果您正苦于以下问题:TypeScript StateRegistry类的具体用法?TypeScript StateRegistry怎么用?TypeScript StateRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了StateRegistry类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: decorator

 /**
  * Decorates states when they are registered
  *
  * Allows you to extend (carefully) or override (at your own peril) the
  * `stateBuilder` object used internally by [[StateRegistry]].
  * This can be used to add custom functionality to ui-router,
  * for example inferring templateUrl based on the state name.
  *
  * When passing only a name, it returns the current (original or decorated) builder
  * function that matches `name`.
  *
  * The builder functions that can be decorated are listed below. Though not all
  * necessarily have a good use case for decoration, that is up to you to decide.
  *
  * In addition, users can attach custom decorators, which will generate new
  * properties within the state's internal definition. There is currently no clear
  * use-case for this beyond accessing internal states (i.e. $state.$current),
  * however, expect this to become increasingly relevant as we introduce additional
  * meta-programming features.
  *
  * **Warning**: Decorators should not be interdependent because the order of
  * execution of the builder functions in non-deterministic. Builder functions
  * should only be dependent on the state definition object and super function.
  *
  *
  * Existing builder functions and current return values:
  *
  * - **parent** `{object}` - returns the parent state object.
  * - **data** `{object}` - returns state data, including any inherited data that is not
  *   overridden by own values (if any).
  * - **url** `{object}` - returns a {@link ui.router.util.type:UrlMatcher UrlMatcher}
  *   or `null`.
  * - **navigable** `{object}` - returns closest ancestor state that has a URL (aka is
  *   navigable).
  * - **params** `{object}` - returns an array of state params that are ensured to
  *   be a super-set of parent's params.
  * - **views** `{object}` - returns a views object where each key is an absolute view
  *   name (i.e. "viewName@stateName") and each value is the config object
  *   (template, controller) for the view. Even when you don't use the views object
  *   explicitly on a state config, one is still created for you internally.
  *   So by decorating this builder function you have access to decorating template
  *   and controller properties.
  * - **ownParams** `{object}` - returns an array of params that belong to the state,
  *   not including any params defined by ancestor states.
  * - **path** `{string}` - returns the full path from the root down to this state.
  *   Needed for state activation.
  * - **includes** `{object}` - returns an object that includes every state that
  *   would pass a `$state.includes()` test.
  *
  * #### Example:
  * Override the internal 'views' builder with a function that takes the state
  * definition, and a reference to the internal function being overridden:
  * ```js
  * $stateProvider.decorator('views', function (state, parent) {
  *   let result = {},
  *       views = parent(state);
  *
  *   angular.forEach(views, function (config, name) {
  *     let autoName = (state.name + '.' + name).replace('.', '/');
  *     config.templateUrl = config.templateUrl || '/partials/' + autoName + '.html';
  *     result[name] = config;
  *   });
  *   return result;
  * });
  *
  * $stateProvider.state('home', {
  *   views: {
  *     'contact.list': { controller: 'ListController' },
  *     'contact.item': { controller: 'ItemController' }
  *   }
  * });
  * ```
  *
  *
  * ```js
  * // Auto-populates list and item views with /partials/home/contact/list.html,
  * // and /partials/home/contact/item.html, respectively.
  * $state.go('home');
  * ```
  *
  * @param {string} name The name of the builder function to decorate.
  * @param {object} func A function that is responsible for decorating the original
  * builder function. The function receives two parameters:
  *
  *   - `{object}` - state - The state config object.
  *   - `{object}` - super - The original builder function.
  *
  * @return {object} $stateProvider - $stateProvider instance
  */
 decorator(name: string, func: BuilderFunction) {
   return this.stateRegistry.decorator(name, func) || this;
 }
开发者ID:angular-ui,项目名称:ui-router,代码行数:92,代码来源:stateProvider.ts


示例2: state

 state(name: any, definition?: any) {
   if (isObject(name)) {
     definition = name;
   } else {
     definition.name = name;
   }
   this.stateRegistry.register(definition);
   return this;
 }
开发者ID:angular-ui,项目名称:ui-router,代码行数:9,代码来源:stateProvider.ts



注:本文中的@uirouter/core.StateRegistry类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript core.StateService类代码示例发布时间:2022-05-28
下一篇:
TypeScript core.StateObject类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap