1 | "use strict";
|
2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7 | };
|
8 | var __metadata = (this && this.__metadata) || function (k, v) {
|
9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10 | };
|
11 | var common_1 = require('@angular/common');
|
12 | var core_1 = require('@angular/core');
|
13 | var lang_1 = require('../facade/lang');
|
14 | var router_1 = require('../router');
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | var RouterLink = (function () {
|
45 | function RouterLink(_router, _location) {
|
46 | var _this = this;
|
47 | this._router = _router;
|
48 | this._location = _location;
|
49 |
|
50 | this._router.subscribe(function (_) { return _this._updateLink(); });
|
51 | }
|
52 |
|
53 |
|
54 | RouterLink.prototype._updateLink = function () {
|
55 | this._navigationInstruction = this._router.generate(this._routeParams);
|
56 | var navigationHref = this._navigationInstruction.toLinkUrl();
|
57 | this.visibleHref = this._location.prepareExternalUrl(navigationHref);
|
58 | };
|
59 | Object.defineProperty(RouterLink.prototype, "isRouteActive", {
|
60 | get: function () { return this._router.isRouteActive(this._navigationInstruction); },
|
61 | enumerable: true,
|
62 | configurable: true
|
63 | });
|
64 | Object.defineProperty(RouterLink.prototype, "routeParams", {
|
65 | set: function (changes) {
|
66 | this._routeParams = changes;
|
67 | this._updateLink();
|
68 | },
|
69 | enumerable: true,
|
70 | configurable: true
|
71 | });
|
72 | RouterLink.prototype.onClick = function () {
|
73 |
|
74 | if (!lang_1.isString(this.target) || this.target == '_self') {
|
75 | this._router.navigateByInstruction(this._navigationInstruction);
|
76 | return false;
|
77 | }
|
78 | return true;
|
79 | };
|
80 | RouterLink = __decorate([
|
81 | core_1.Directive({
|
82 | selector: '[routerLink]',
|
83 | inputs: ['routeParams: routerLink', 'target: target'],
|
84 | host: {
|
85 | '(click)': 'onClick()',
|
86 | '[attr.href]': 'visibleHref',
|
87 | '[class.router-link-active]': 'isRouteActive'
|
88 | }
|
89 | }),
|
90 | __metadata('design:paramtypes', [router_1.Router, common_1.Location])
|
91 | ], RouterLink);
|
92 | return RouterLink;
|
93 | }());
|
94 | exports.RouterLink = RouterLink;
|
95 |
|
\ | No newline at end of file |