David Rocha
David Rocha

Reputation: 549

AngularJS Application do not running using ui-router

I am trying to use ui-router in a new project, I followed many tutorials and documentation, but I cant't understand why my application is not launching. I am in the very start and do not have too much code. Maybe I am missing something? I am not having error in console, everything I have is a completly white page.

This is my 'app.js' with the config:

(function () {
'use strict';

angular.module('clicko', ['ui.router'])
    .config(['$stateProvider', '$logProvider', function ($stateProvider, $logProvider) {

        $logProvider.debugInfoEnabled = true;

        $stateProvider
            .state('dashboard', {
                url: '/',
                controller: 'app/dashboard/dashboardController',
                controllerAs: 'dashboard',
                templateUrl: 'app/dashboard/dashboard.html'
            });
    }
]);

})();

and this is my 'dashboardController.js':

(function () {
'use strict';

function controller($location) {
    /* jshint validthis:true */
    var vm = this;
    vm.greet = 'Heeeello World!';

    function activate() {
        alert('go');
    }

    activate();
}


////
angular
    .module('clicko')
    .controller('dashboard', controller);


controller.$inject = ['$location'];

})();

and this is my 'dashboard.html'

<h1>Dashboard</h1>

<h2>{{dashboard.greet}}</h2>

<p>Lorem ipsum dolor sit amet</p>

'index.html'

<body ng-app="clicko">

<div ui-view></div>

<!--SCRIPTS-->
<!-- ANGULARJS -->
<script src="app/assets/libs/jquery/dist/jquery.min.js"></script>
<script src="app/assets/libs/angular/angular.min.js"></script>
<script src="app/assets/libs/angular-ui-router/release/angular-ui-router.min.js"></script>

<!--APP-->
<script src="app/app.js"></script>

<!--CONTROLLLERS-->
<script src="app/dashboard/dashboardController.js"></script>

Can Somebody help me?

EDIT

Here is a plunkr: https://plnkr.co/edit/OEl278DxxB1N0xECsJwk?p=preview

Upvotes: 0

Views: 44

Answers (1)

Tarun Dugar
Tarun Dugar

Reputation: 8971

One problem is:

controller: 'app/dashboard/dashboardController',

This value for the key 'controller' should be the controller name and not its path. So, change it to:

controller: 'dashboard',

EDIT:

Working plunkr here.

I changed the state to following:

.state('dashboard', {
     url: '', //changed from '/' to ''
     controller: 'dashboard',
     templateUrl: 'dashboard.html' //the path specified was wrong
})

Upvotes: 1

Related Questions