I created a plunker showing / explaining the problem.
The fact is that this is a child state:
.state('accounts.add', { url: "/add", views: { 'content': { templateUrl: "/accounts/add" } }
has the same idea as its parent: 'content'. This means that it does not mean that they are aimed at the same view. No - the child is looking for a view in the parent element - with the same name as content .
The purpose of the parent state ( accounts ) is Index.html (in ASP.NET MVC / home /):
<body> <div ui-view="content" ></div> </body>
The purpose of the child state ( accounts.add ) is templateUrl: "/dashboard/index" :
<div> ... parent content ... ... and here is the place holder for child state (with the same name) ... "content" <div ui-view="content" ></div> </div>
How to target root ui-view="content" (index.html) is to use absolute naming. In plunker, I used the Insert state for this:
.state('accounts.insert', { url: "/insert", views: { ' content@ ': { templateUrl: "accounts.insert.tpl.html" } }
Where in the view name is ' content@ ' @ I am a way to target the root. See the documentation for more details:
Small extract:
views: { //////////////////////////////////// // Relative Targeting // // Targets parent state ui-view // //////////////////////////////////// // Relatively targets the 'detail' view in this state parent state, 'contacts'. // <div ui-view='detail'/> within contacts.html "detail" : { }, // Relatively targets the unnamed view in this state parent state, 'contacts'. // <div ui-view/> within contacts.html "" : { }, /////////////////////////////////////////////////////// // Absolute Targeting using '@' // // Targets any view within this state or an ancestor // /////////////////////////////////////////////////////// // Absolutely targets the 'info' view in this state, 'contacts.detail'. // <div ui-view='info'/> within contacts.detail.html " info@contacts.detail " : { } // Absolutely targets the 'detail' view in the 'contacts' state. // <div ui-view='detail'/> within contacts.html " detail@contacts " : { } // Absolutely targets the unnamed view in parent 'contacts' state. // <div ui-view/> within contacts.html "@contacts" : { } // absolutely targets the 'status' view in root unnamed state. // <div ui-view='status'/> within index.html " status@ " : { }
source share