Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJs and landing page

A landing page is often totally different than the look and feel of other pages.

Basically, with the default routing mechanism of angular, index.html could have an ng-view in order to display the various pages.
There is not concept of "conditions" with this ng-view.

Indeed, what if I want to specify some navigation bar to all pages but landing page?

Should I "include" a navigation bar to each of those templates, breaking DRY principle?

like image 615
Mik378 Avatar asked Nov 11 '22 10:11

Mik378


1 Answers

I did that by using angular-ui-router https://github.com/angular-ui/ui-router/wiki

With Angular UI Router You can define states instead but you need to pub/sub the state back to your navigation component.

Angular ui Router allows you to nest views so you don't need to put the navigation outside of the view which would result in reloading the page being out of your view.

Just a note ui router is using ui-sref directive to navigate instead of ng-href. This could be a lot of work for reforging your project But I believe it worth it.

About changing your Navigation. You can have your navigation wrapped in an ng-if or ng-show directive or you can have a completely different base template on your / , /home state.

Cheers

like image 145
Alexandros Spyropoulos Avatar answered Nov 15 '22 11:11

Alexandros Spyropoulos