Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Andrey Shilov
Ngx Bootstrap
Commits
e7dd76b0
Commit
e7dd76b0
authored
8 years ago
by
Oleksandr Telnov
Committed by
Dmitriy Shekhovtsov
8 years ago
Browse files
Options
Download
Email Patches
Plain Diff
chore(demo): use routerLinkActive instead of custom method (#743)
parent
2b95c95b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
demo/components/main-menu/main-menu.component.ts
+1
-4
demo/components/main-menu/main-menu.component.ts
demo/components/main-menu/main-menu.template.html
+3
-20
demo/components/main-menu/main-menu.template.html
demo/config.ts
+1
-3
demo/config.ts
demo/index.ts
+1
-2
demo/index.ts
with
6 additions
and
29 deletions
+6
-29
demo/components/main-menu/main-menu.component.ts
View file @
e7dd76b0
...
...
@@ -22,14 +22,11 @@ export class MainMenuComponent {
public
hash
:
string
=
''
;
public
constructor
(
private
router
:
Router
)
{
this
.
routes
=
this
.
routes
.
filter
((
v
:
any
)
=>
v
.
path
!==
'
**
'
);
this
.
router
.
events
.
subscribe
((
event
:
any
)
=>
{
if
(
event
instanceof
NavigationEnd
)
{
this
.
hash
=
event
.
url
;
}
});
}
public
isActive
(
link
:
string
):
boolean
{
return
this
.
hash
.
substring
(
1
)
===
link
;
}
}
This diff is collapsed.
Click to expand it.
demo/components/main-menu/main-menu.template.html
View file @
e7dd76b0
...
...
@@ -10,26 +10,9 @@
</div>
<div
class=
"section"
*ngFor=
"let route of routes | SearchFilter:search.text"
[class.active]=
"isActive(route.path)"
>
<h3
[routerLink]=
"[route.path]"
>
{{route.data[0]}}
</h3>
<!-- <div class="item">
<h4>
<span [routerLink]="[route.name]">Example</span>
</h4>
</div>
<div class="item">
<h4>
<span [routerLink]="[route.name]">Api</span>
</h4>
</div>
<div class="item">
<h4>
<span [routerLink]="[route.name]">Properties</span>
</h4>
</div>-->
[routerLinkActive]=
"['active']"
[routerLinkActiveOptions]=
"{exact: true}"
>
<a
[routerLink]=
"[route.path]"
><h3>
{{route.data[0]}}
</h3></a>
</div>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
demo/config.ts
View file @
e7dd76b0
...
...
@@ -84,9 +84,7 @@ export const routes:RouterConfig = [
component
:
TypeaheadSectionComponent
},
{
path
:
'
**
'
,
redirectTo
:
''
,
data
:
[
'
Getting started
'
],
component
:
GettingStartedSectionComponent
redirectTo
:
'
/
'
}
];
...
...
This diff is collapsed.
Click to expand it.
demo/index.ts
View file @
e7dd76b0
...
...
@@ -4,7 +4,7 @@ import {Ng2BootstrapConfig, Ng2BootstrapTheme} from '../ng2-bootstrap';
import
{
MainMenuComponent
}
from
'
./components/main-menu/main-menu.component
'
;
import
{
TopMenuComponent
}
from
'
./components/top-menu/top-menu.component
'
;
import
{
bootstrap
}
from
'
@angular/platform-browser-dynamic
'
;
import
{
APP_BASE_HREF
,
HashLocationStrategy
,
LocationStrategy
}
from
'
@angular/common
'
;
import
{
HashLocationStrategy
,
LocationStrategy
}
from
'
@angular/common
'
;
import
{
APP_ROUTER_PROVIDERS
}
from
'
./config
'
;
import
{
ROUTER_DIRECTIVES
,
Router
,
NavigationEnd
}
from
'
@angular/router
'
;
...
...
@@ -56,6 +56,5 @@ bootstrap(DemoComponent, [
APP_ROUTER_PROVIDERS
,
disableDeprecatedForms
(),
provideForms
(),
{
provide
:
APP_BASE_HREF
,
useValue
:
'
/
'
},
{
provide
:
LocationStrategy
,
useClass
:
HashLocationStrategy
}
]);
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help