AngularJS UI-Router parent


I’m using UI-Router for a project of mine and I just noticed that when I reload a child state the controller for the parent also runs (again) along with the child controller. The scope from the parent gets inherited by the child. Is this supposed to work like this? Can I isolate the child scope?

I need the parent/child relation to get breadcrumbs to work.

app.config(function($stateProvider, $urlRouterProvider) {
	.state('parent', {
		name: 'parent',
		url: '/parent',
		templateUrl: 'parent-template.html',
		controller: 'parentController',  		
	.state('child', {
		name: 'child',
		parent: 'parent',
		url: '/child',
		templateUrl: 'child-template.html',
		controller: 'childController',
	.state('orphan', {
		name: 'orphan',
		url: '/orphan',
		templateUrl: 'orphan-template.html',
		controller: 'orphanController',
	// if no route is matching
<!-- INDEX.HTML -->
    <div ng-app="app">
      <main role="main" class="container">
        <div ng-app="app">

	<div class="container">
		parent content

	<div class="container">
		child content

<div class="container">
	Orphan Content


The controller are instantiated because the view is showing. Try to use named views:

The UI-ROuter are a powerfull tool with a huge great options but “great power comes great responsibility” on my own experience all its options got me lost lot of time, to test and understand. Finally the best (but not the easeast) is try to use it as simple as posible.

Answered By – pdorgambide

Answer Checked By – Jay B. (AngularFixing Admin)

Leave a Reply

Your email address will not be published.