angular ui route Error as Could not resolve 'Employee.root' from state when abstract =true

Issue

why im getting this Error Could not resolve ‘Employee.root’ from state
when im using abstract true.

<body ng-app="SuperApp">
                <li><a ui-sref="Employee.root()">Employees</a></li>

.js code

app.config(function ($stateProvider, $urlRouterProvider, $locationProvider) {
    $urlRouterProvider.otherwise('/')
    $stateProvider
        .state('root', {
            abstract:true,
            views:{
                '@':{
                    templateUrl: '/Kpmg/Dummy/_LayoutPage.html'
                }
            }

        })
    $stateProvider.state('root.Employee', {
        url: 'contact',
        templateUrl: '/Kpmg/Dummy/someOther/Contact1.html',
        controller: 'abc'
    })

Contact1.html

  <div ng-controller="abc">
        <h3>This is Contact</h3>
    </div>
  <div ui-view></div>

Solution

It should be

  <li><a ui-sref="root.Employee">Employees</a></li>

Answered By – Sajeetharan

Answer Checked By – Terry (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.