0

I started developing a new application in AngularJS 2 and I got stuck planning it.

I got a bootstrap template with a sidebar menu and a content div.

Sample of HTML:

<html>
<head>
...
</head>
<body>
  <ul class="sidebar">
    <li><a [routerLink]="Test">Test</a></li>
  </ul>
  <app-selector>...</app-selector>
</body>
</html>

How can I build this structure, using routerLink outside an Angular component? Should I configure these RouteConfigs in main component (which bootstraps my main component)?

  • You can't use Angular directives outside Angular components. You probably can implement a `SidebarComponent`, and have it be a part of your `AppComponent`, or does it not suite your needs? – Dethariel Jul 29 '16 at 21:40
  • I tried that, but when I change my route, my app desappears and the new template appears. But, my sidebar goes away with my entire template. – Claudio Neto Jul 29 '16 at 21:44
  • Put your content inside `` This way your sidebar wont disappear when you navigate. If you have a component for sidebar as well and want to navigate from there, then you might want to create a navigation service. – JukkaL Jul 29 '16 at 21:47
  • Can you please post at least an excerpt from your `app-selector` template? It can be that the app layout is wrong – Dethariel Jul 29 '16 at 21:48
  • I tried that, @JukkaL, but I realized my angular2/router was not loaded. I fixed that and still having problems. – Claudio Neto Jul 29 '16 at 22:53

0 Answers0