As above so below
As above so below

Reputation: 799

Using ui-router with AngularJS 1.6. components

I have recently switched to AngularJS 1.6. to make it easier to move to Angular2 and beyond if necessary. In a sample app I'm trying to create, I'm having trouble setting up ui-router 1.0 for components. Here is what I've tried so far:

import { DashboardComponent } from './ng/dashboard.component.js';
import uiRouter from "@uirouter/angularjs";

export default angular
    .module('dashboardModule', ['ui.router'])
    .component('dashboard', DashboardComponent)
    .config(function($stateProvider) {
        $stateProvider
            .state('home'), {
                url: '/',
                component: 'dashboard'
            }
    })

which gives the following error:

Error: [$injector:modulerr] Failed to instantiate module dashboardModule due to:
TypeError: Cannot set property 'name' of undefined at StateProvider.state 

What am I missing ?

Upvotes: 1

Views: 624

Answers (1)

XPX-Gloom
XPX-Gloom

Reputation: 601

state options should be part of state definition.

.state('home', {
    url: '/',
    component: 'dashboard'
})

Upvotes: 4

Related Questions