0

Here is my index page

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="../Scripts/angular.js"></script>
    <script src="../Scripts/angular-ui-router.js"></script>
    <script src="js/NestedApp.js"></script>
</head>
<body ng-app="customApp">
    Index Level
    <a ui-sref="FirstPage">FirstPage</a>
    <div ui-view></div>

</body>
</html>

Here is my FirstPage

  <h1>Settings Level</h1>
    <hr />
    <a ui-sref="Firstpage.profile">Profile</a>
    <a ui-sref="Firstpage.account">Account</a>
    <div ui-view></div>

Here is my route,js

var app = angular.module('customApp', ['ui.router']);

app.config(function ($stateProvider, $urlRouterProvider) {
    $stateProvider
        .state('FirstPage',
        {
            //url:'/',
            url: '/',

            templateUrl: 'FirstPage.html',

        })
        .state('Firstpage.profile', {
            url:'/profile',
            templateUrl: '../profile.html'

        });

    $urlRouterProvider.otherwise('/FirstPage');
})

First Level routing works fine

Here is url for the first level routing http://localhost:59367/app/customIndex.html#/

When i click Profile link, here is the error i m getting

Error: Could not resolve 'Firstpage.profile' from state 'FirstPage'

Can someone help me with this

1 Answer 1

1

if you rename FirstPage to Firstpage then you will not have any problem.

this is because UI-Router consider FirstPage != Firstpage

your new states should be:

.state('Firstpage',
        {
            //url:'/',
            url: '/',

            templateUrl: 'FirstPage.html',

        })
        .state('Firstpage.profile', {
            url:'/profile',
            templateUrl: '../profile.html'

        });

and your ui-sref in root will change to:

<a ui-sref="Firstpage">FirstPage</a>
Sign up to request clarification or add additional context in comments.

2 Comments

the only problem is that Firstpage is spelled different
Thanks ... Just before I figured it out and was about to post the same but I got the answer from you as well. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.