I have states mentioned like this
$stateProvider
.state('dashboard', {
url: "/dashboard",
views: {
content: { templateUrl: "/dashboard/index" }
}
}).state('accounts', {
url: "/accounts",
views: {
'content': { templateUrl: "/accounts/index" }
}
})
.state('accounts.add', {
url: "/add",
views: {
'content': { templateUrl: "/accounts/add" }
}
});
and the URLS are
<a class="list-group-item submenu" ui-sref="accounts">Service Users</a>
<a class="list-group-item submenu" ui-sref="accounts.add">Add User</a>
I am using asp.net Mvc so my Controller which serves the templates currently looks like this
public class AccountsController : Controller
{
//
// GET: /Accounts/
public ActionResult Index()
{
return Request.IsAjaxRequest() ? (ActionResult)PartialView("_Icons") : View();
}
public ActionResult Add()
{
return Request.IsAjaxRequest() ? (ActionResult)PartialView("_Add") : View();
}
}
But whenever I make request to the state accounts.add then it always calls the accounts state .And renders the _icons view which is nothing but a partial view as _icons.cshtml. I can see in firebug that url has been called but it never gets rendered . WHY ????
The firebug output is something like this
GET http://localhost:2060/accounts/index 200 OK 2ms
GET http://localhost:2060/accounts/add 200 OK 5ms
This is what happens when I click ui-sref="accounts.add" and ends up rendering the index action . Can someone tell me why is this happening ? It shouldn't be happening . Is there something which I am missing out as convention from ui-router ?