# Issue in nested views

**URL:** <https://forum.ionicframework.com/t/issue-in-nested-views/2479>\
**Category:** ionic-v1\
**Created:** [March 31, 2014, 10:05pm UTC](https://forum.ionicframework.com/t/issue-in-nested-views/2479 "2014-03-31T22:05:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankisinghal](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@ankisinghal](https://forum.ionicframework.com/u/ankisinghal)\
**Post date:** [March 31, 2014, 10:05pm UTC](https://forum.ionicframework.com/t/issue-in-nested-views/2479/1 "2014-03-31T22:05:56Z")

</div>

HI

I am trying to use nested views , but getting some javascript error like:

**Uncaught TypeError: Cannot call method ‘insertBefore’ of null : ionic-bundle:10255**

I am trying to make a OrderPage with 2 subpages:

**ordermedicine.html:**

```
  <ion-view name="selectstore">
 </ion-view>
 <ion-view name="patientdetails">
 </ion-view>

```

**statemanagement:**

```
.state('order', {
      url: '/order',
      abstract: true,
	  templateUrl: 'partials/ordermedicine.html',
	  controller: 'OrderMedicineCtrl'
    })
	.state('order.selectstore', {
      url: '/selectstore',
      views: {
        'selectstore': {
          templateUrl: "partials/order_selectstore.html",
          controller: 'OrderMedicineCtrl'
       }
      }
    })
	.state('order.patientdetails', {
      url: '/patientdetails',
       views: {
        'patientdetails': {
          templateUrl: "partials/order_patientdetails.html",
          controller: 'OrderMedicineCtrl'
        }
      }
    })

```

**Controller:**

```
    .controller('OrderMedicineCtrl', function($scope, $state) {
		$scope.patientdetails = function() {
		   console.log('patientdetails');
			$state.go('order.patientdetails');
		  };
		$scope.medicinedetails = function() {
		   console.log('medicinedetails');
			$state.go('order.medicinedetails');
		  }; 
		$scope.deliverydetails = function() {
		   console.log('deliverydetails');
			$state.go('order.deliverydetails');
		  }; 
		$scope.confirmorder = function() {
		   console.log('confirmorder');
			$state.go('order.confirmorder');
		  }; 		  
  })

```

**order\_selectstore.html**

```
<ion-view title="Select Store">
	<ion-content>
		<a class="button icon-right ion-chevron-right button-calm" ng-click="patientdetails()">Enter Patient Details</a>
	</ion-content>
</ion-view>

```

**order\_pateintdetails.html**

```
<ion-view title="Patient Details">
	<ion-content>
		<a class="button icon-right ion-chevron-right button-calm" ng-click="medicinedetails()">Enter Medicine Details</a>
	</ion-content>
</ion-view>

```

The same nested states concept however works for Tabbing. Am I missing anything basic here?

---

<div class="post-metadata">

**Author:** ![gnomeontherun](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/gnomeontherun/32/64484_2.png) [@gnomeontherun](https://forum.ionicframework.com/u/gnomeontherun)\
**Post date:** [March 31, 2014, 11:33pm UTC](https://forum.ionicframework.com/t/issue-in-nested-views/2479/2 "2014-03-31T23:33:15Z")

</div>

Making it a plunkr or codepen example would be helpful so I can interact with it, but for **ordermedicine.html**

I believe you should use `<ion-nav-view>` instead of `<ion-view>`. `ionNavView` is the directive to use when in a template to load the children partials into, and `ionView` is the wrapper around the children partials.

---

<div class="post-metadata">

**Author:** ![ankisinghal](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@ankisinghal](https://forum.ionicframework.com/u/ankisinghal)\
**Post date:** [April 1, 2014, 12:22pm UTC](https://forum.ionicframework.com/t/issue-in-nested-views/2479/3 "2014-04-01T12:22:19Z")

</div>

> **[Plunker - blank start for](http://plnkr.co/edit/z9ogop)**
>
> Created on https://plnkr.co: Helping you build the web.

here is the link.

Idea is simple to have ordershome.html as parent and storedetails and patientdetails as child.

---

<div class="post-metadata">

**Author:** ![ankisinghal](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@ankisinghal](https://forum.ionicframework.com/u/ankisinghal)\
**Post date:** [April 2, 2014, 6:35pm UTC](https://forum.ionicframework.com/t/issue-in-nested-views/2479/4 "2014-04-02T18:35:33Z")

</div>

any suggestions on this ??

---

<div class="post-metadata">

**Author:** ![Calendee](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/calendee/32/13656_2.png) [@Calendee](https://forum.ionicframework.com/u/Calendee)\
**Post date:** [April 3, 2014, 12:50pm UTC](https://forum.ionicframework.com/t/issue-in-nested-views/2479/5 "2014-04-03T12:50:58Z")

</div>

I’m no ui-router expert, but got it to work like this :

See this fixed sample : [http://plnkr.co/edit/htE6yv?p=preview](http://plnkr.co/edit/htE6yv?p=preview)

The problem is that you were using `ion-nav-view` in “ordershome.html”. I changed those to :

```auto
  <ui-view name="selectstore">
	</ui-view>
  <ui-view name="patientdetails">
	</ui-view>

```

I’m not really sure if this is the best/correct way. You might want to experiment some more with it.

---

<div class="post-metadata">

**Author:** ![ankisinghal](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@ankisinghal](https://forum.ionicframework.com/u/ankisinghal)\
**Post date:** [April 3, 2014, 2:27pm UTC](https://forum.ionicframework.com/t/issue-in-nested-views/2479/6 "2014-04-03T14:27:22Z")

</div>

Thanks ,… but this is strange … 😄

But I think with this navigation might not work as @gnomeontherun mentioned. However in reality it is working fine…

Anyways thanks again 😄
