Skip to content

Commit

Permalink
docs(*): improve ng1 docs
Browse files Browse the repository at this point in the history
docs(injectables): list all injectable objects
feat(injectables): Expose `$uiRouterProvider`, `$uiRouterGlobals`, and `$stateRegistry` injectables
  • Loading branch information
christopherthielen committed Dec 11, 2016
1 parent c8162ee commit 7fa72a6
Show file tree
Hide file tree
Showing 7 changed files with 369 additions and 273 deletions.
16 changes: 12 additions & 4 deletions src/directives/stateDirectives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* These directives are used in templates to create viewports and navigate to states
*
* @preferred @module ng1_directives
* @ng1api @preferred @module directives
*/ /** for typedoc */
import { ng as angular } from "../angular";
import { IAugmentedJQuery, ITimeoutService, IScope, IInterpolateService } from "angular";
Expand All @@ -14,6 +14,9 @@ import {
} from "ui-router-core";
import { UIViewData } from "./viewDirective";

/** @hidden Used for typedoc */
export interface ng1_directive {}

/** @hidden */
function parseStateRef(ref: string) {
let paramsOnly = ref.match(/^\s*({[^}]*})\s*$/), parsed;
Expand Down Expand Up @@ -211,7 +214,8 @@ function defaultOpts(el: IAugmentedJQuery, $state: StateService) {
* - Unlike the parameter values expression, the state name is not `$watch`ed (for performance reasons).
* If you need to dynamically update the state being linked to, use the fully dynamic [[uiState]] directive.
*/
let uiSref = ['$uiRouter', '$timeout',
let uiSref: ng1_directive;
uiSref = ['$uiRouter', '$timeout',
function $StateRefDirective($uiRouter: UIRouter, $timeout: ITimeoutService) {
let $state = $uiRouter.stateService;

Expand Down Expand Up @@ -334,7 +338,8 @@ let uiSref = ['$uiRouter', '$timeout',
* - A middle-click, right-click, or ctrl-click is handled (natively) by the browser to open the href in a new window, for example.
* ```
*/
let uiState = ['$uiRouter', '$timeout',
let uiState: ng1_directive;
uiState = ['$uiRouter', '$timeout',
function $StateRefDynamicDirective($uiRouter: UIRouter, $timeout: ITimeoutService) {
let $state = $uiRouter.stateService;

Expand Down Expand Up @@ -469,7 +474,8 @@ let uiState = ['$uiRouter', '$timeout',
*
* - Multiple classes may be specified in a space-separated format: `ui-sref-active='class1 class2 class3'`
*/
let uiSrefActive = ['$state', '$stateParams', '$interpolate', '$uiRouter',
let uiSrefActive: ng1_directive;
uiSrefActive = ['$state', '$stateParams', '$interpolate', '$uiRouter',
function $StateRefActiveDirective($state: StateService, $stateParams: Obj, $interpolate: IInterpolateService, $uiRouter: UIRouter) {
return {
restrict: "A",
Expand Down Expand Up @@ -564,7 +570,9 @@ let uiSrefActive = ['$state', '$stateParams', '$interpolate', '$uiRouter',
};
}];

/** @hidden */
interface Def { uiState: string; href: string; uiStateParams: Obj; uiStateOpts: any; }
/** @hidden */
interface StateData { state: StateDeclaration; params: RawParams; activeClass: string; }

angular.module('ui.router.state')
Expand Down
26 changes: 15 additions & 11 deletions src/directives/viewDirective.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @module ng1_directives */ /** for typedoc */
/** @ng1api @module directives */ /** for typedoc */
import { ng as angular } from "../angular";
import {
IInterpolateService, IScope, ITranscludeFunction, IAugmentedJQuery,
Expand All @@ -13,6 +13,7 @@ import {
import {Ng1ViewConfig} from "../statebuilders/views";
import {Ng1Controller, Ng1StateDeclaration} from "../interface";
import {getLocals} from "../services";
import { ng1_directive } from "./stateDirectives";

/** @hidden */
export type UIViewData = {
Expand All @@ -30,18 +31,17 @@ export type UIViewAnimData = {
/**
* `ui-view`: A viewport directive which is filled in by a view from the active state.
*
* @param {string=} name A view name. The name should be unique amongst the other views in the
* same state. You can have views of the same name that live in different states.
* ### Attributes
*
* @param {string=} autoscroll It allows you to set the scroll behavior of the browser window
* when a view is populated. By default, $anchorScroll is overridden by ui-router's custom scroll
* service, {@link ui.router.state.$uiViewScroll}. This custom service let's you
* scroll ui-view elements into view when they are populated during a state activation.
* - `name`: (Optional) A view name.
* The name should be unique amongst the other views in the same state.
* You can have views of the same name that live in different states.
* The ui-view can be targeted in a View using the name ([[Ng1StateDeclaration.views]]).
*
* *Note: To revert back to old [`$anchorScroll`](http://docs.angularjs.org/api/ng.$anchorScroll)
* functionality, call `$uiViewScrollProvider.useAnchorScroll()`.*
* - `autoscroll`: an expression. When it evaluates to true, the `ui-view` will be scrolled into view when it is activated.
* Uses [[$uiViewScroll]] to do the scrolling.
*
* @param {string=} onload Expression to evaluate whenever the view updates.
* - `onload`: Expression to evaluate whenever the view updates.
*
* A view can be unnamed or named.
* @example
Expand All @@ -52,6 +52,9 @@ export type UIViewAnimData = {
*
* <!-- Named -->
* <div ui-view="viewName"></div>
*
* <!-- Named (different style) -->
* <ui-view name="viewName"></ui-view>
* ```
*
* You can only have one unnamed view within any template (or root html). If you are only using a
Expand Down Expand Up @@ -155,7 +158,8 @@ export type UIViewAnimData = {
* });
* ```
*/
let uiView = ['$view', '$animate', '$uiViewScroll', '$interpolate', '$q',
let uiView: ng1_directive;
uiView = ['$view', '$animate', '$uiViewScroll', '$interpolate', '$q',
function $ViewDirective($view: ViewService, $animate: any, $uiViewScroll: any, $interpolate: IInterpolateService, $q: $QLike) {

function getRenderer(attrs: Obj, scope: IScope) {
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export * from "./services";
export * from "./statebuilders/views";
export * from "./stateProvider";

import "./injectables";
import "./directives/stateDirectives";
import "./stateFilters";
import "./directives/viewDirective";
Expand Down
Loading

0 comments on commit 7fa72a6

Please sign in to comment.