UNPKG

4.55 kBSource Map (JSON)View Raw
1{"version":3,"file":"router_link.js","sourceRoot":"","sources":["../../../../../modules/@angular/router-deprecated/src/directives/router_link.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,uBAAuB,iBAAiB,CAAC,CAAA;AACzC,qBAAwB,eAAe,CAAC,CAAA;AAExC,qBAAuB,gBAAgB,CAAC,CAAA;AAExC,uBAAqB,WAAW,CAAC,CAAA;AAGjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAUH;IAUE,oBAAoB,OAAe,EAAU,SAAmB;QAVlE,iBAsCC;QA5BqB,YAAO,GAAP,OAAO,CAAQ;QAAU,cAAS,GAAT,SAAS,CAAU;QAC9D,gFAAgF;QAChF,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,UAAC,CAAC,IAAK,OAAA,KAAI,CAAC,WAAW,EAAE,EAAlB,CAAkB,CAAC,CAAC;IACpD,CAAC;IAED,mFAAmF;IACnF,qEAAqE;IAC7D,gCAAW,GAAnB;QACE,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACvE,IAAI,cAAc,GAAG,IAAI,CAAC,sBAAsB,CAAC,SAAS,EAAE,CAAC;QAC7D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;IACvE,CAAC;IAED,sBAAI,qCAAa;aAAjB,cAA+B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;;;OAAA;IAEhG,sBAAI,mCAAW;aAAf,UAAgB,OAAc;YAC5B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;YAC5B,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,CAAC;;;OAAA;IAED,4BAAO,GAAP;QACE,wEAAwE;QACxE,EAAE,CAAC,CAAC,CAAC,eAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC;YACrD,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YAChE,MAAM,CAAC,KAAK,CAAC;QACf,CAAC;QACD,MAAM,CAAC,IAAI,CAAC;IACd,CAAC;IA9CH;QAAC,gBAAS,CAAC;YACT,QAAQ,EAAE,cAAc;YACxB,MAAM,EAAE,CAAC,yBAAyB,EAAE,gBAAgB,CAAC;YACrD,IAAI,EAAE;gBACJ,SAAS,EAAE,WAAW;gBACtB,aAAa,EAAE,aAAa;gBAC5B,4BAA4B,EAAE,eAAe;aAC9C;SACF,CAAC;;kBAAA;IAuCF,iBAAC;AAAD,CAAC,AAtCD,IAsCC;AAtCY,kBAAU,aAsCtB,CAAA","sourcesContent":["import {Location} from '@angular/common';\nimport {Directive} from '@angular/core';\n\nimport {isString} from '../facade/lang';\nimport {Instruction} from '../instruction';\nimport {Router} from '../router';\n\n\n/**\n * The RouterLink directive lets you link to specific parts of your app.\n *\n * Consider the following route configuration:\n\n * ```\n * @RouteConfig([\n * { path: '/user', component: UserCmp, name: 'User' }\n * ]);\n * class MyComp {}\n * ```\n *\n * When linking to this `User` route, you can write:\n *\n * ```\n * <a [routerLink]=\"['./User']\">link to user component</a>\n * ```\n *\n * RouterLink expects the value to be an array of route names, followed by the params\n * for that level of routing. For instance `['/Team', {teamId: 1}, 'User', {userId: 2}]`\n * means that we want to generate a link for the `Team` route with params `{teamId: 1}`,\n * and with a child route `User` with params `{userId: 2}`.\n *\n * The first route name should be prepended with `/`, `./`, or `../`.\n * If the route begins with `/`, the router will look up the route from the root of the app.\n * If the route begins with `./`, the router will instead look in the current component's\n * children for the route. And if the route begins with `../`, the router will look at the\n * current component's parent.\n */\n@Directive({\n selector: '[routerLink]',\n inputs: ['routeParams: routerLink', 'target: target'],\n host: {\n '(click)': 'onClick()',\n '[attr.href]': 'visibleHref',\n '[class.router-link-active]': 'isRouteActive'\n }\n})\nexport class RouterLink {\n private _routeParams: any[];\n\n // the url displayed on the anchor element.\n visibleHref: string;\n target: string;\n\n // the instruction passed to the router to navigate\n private _navigationInstruction: Instruction;\n\n constructor(private _router: Router, private _location: Location) {\n // we need to update the link whenever a route changes to account for aux routes\n this._router.subscribe((_) => this._updateLink());\n }\n\n // because auxiliary links take existing primary and auxiliary routes into account,\n // we need to update the link whenever params or other routes change.\n private _updateLink(): void {\n this._navigationInstruction = this._router.generate(this._routeParams);\n var navigationHref = this._navigationInstruction.toLinkUrl();\n this.visibleHref = this._location.prepareExternalUrl(navigationHref);\n }\n\n get isRouteActive(): boolean { return this._router.isRouteActive(this._navigationInstruction); }\n\n set routeParams(changes: any[]) {\n this._routeParams = changes;\n this._updateLink();\n }\n\n onClick(): boolean {\n // If no target, or if target is _self, prevent default browser behavior\n if (!isString(this.target) || this.target == '_self') {\n this._router.navigateByInstruction(this._navigationInstruction);\n return false;\n }\n return true;\n }\n}\n"]}
\No newline at end of file