0

In an angularjs application, is it possible to use a different (index.html?) for login page and use another index.html page for rest of the pages in the application?

1
  • Its possible but not by taking a pure angular approach to SPA. I'd say that if you're trying to have more than one main page you have missed the point and power of a properly designed SPA Commented Jul 7, 2016 at 13:11

2 Answers 2

1

It is possible, however you can also use ng-if on the login html code and the regular html code:

<div ng-if="userLoggedIn">
   <login page html>
</div>

<div ng-if="!userLoggedIn">
   <regular page html>
</div>

Which will show one of the divs according to what is set as $scope.userLoggedIn in your main controller.

Sign up to request clarification or add additional context in comments.

Comments

0

also you can use ng-show and ng-hide

<div ng-show="userLoggedIn">
   <login page html>
</div>

<div ng-hide="!userLoggedIn">
   <regular page html>
</div>

1 Comment

ng-show and ng-hide actually load the html and set display:none. This means that even if you are not logged in, the regular html page will still get loaded, then it will be hidden once the scope variables are set.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.