0

I am new in angular js, i want create a app using multiple ngview please help me

Index.html

<html ng-app="firstGenApp">
<body>
<div >
    <ng-view></ng-view>
</div>
</body>

1)here i include login.html while loading index.html

Login.html

<h1>Login Page</h1>
<form ng-submit="login(userName, userPass)" ng-controller="LoginCtrl" class="ng-scope ng-pristine ng-valid">
    <label>User name</label>
    <input type="text" ng-model="userName" class="ng-pristine ng-valid">
    <label>Password</label>
    <input type="password" ng-model="userPass" class="ng-pristine ng-valid">
    <br/>
        {{loginError}}  {{loggedUser}}
    <br/><br/>
    <button class="btn btn-success" ng-click="">Login</button>
    <button class="btn btn-warning" ng-click="cancel()">Cancel</button>
</form>

2)after login success i am including homepage.html

Homepage.html

<div ng-view></div>

3) while including homepage.html its giving error

4) This homepage.html having one ng-view i want use this ng-view after including abc.html etc.. please help me how to use multiple ng-view ?

GuN's
  • 21
  • 4
  • Just a hint. There is already a library solving the issue with many views: the angular js `ui-router`. Try to observe it https://github.com/angular-ui/ui-router/wiki. Here I tried to put some other links together... http://stackoverflow.com/a/24693129/1679310 ... I would say that this could save lot of coding for you ... just a suggestion ;) – Radim Köhler Jul 18 '14 at 09:38

1 Answers1

0

You can have only one ng-view per angularjs application.

You can change its content in several ways: ng-include, ng-switch or mapping different controllers and templates through the $routeProvider.

If you want to have nested views, or multiple parallel views, then you definitely want to try UI-Router : https://github.com/angular-ui/ui-router

Raghavendra
  • 5,281
  • 4
  • 36
  • 51