1

Im just staring AngularJS app for 1st time. Followed some steps from tutorials but at the end ui router is not showing anything. Firebug is not showing any JS errors or warnings

my app.js file:

var app = angular.module("CRI", ["ui.router"]);

    app.config(function ($stateProvider) {

        $stateProvider
            .state("Login", {
                url: "/",
                controller: "LoginController",
                templateUrl: "views/login.html"
            })
    })

index.html file:

<!DOCTYPE html >
<html ng-app="CRI">
    <head>
        <title>LOGIN</title>
        <meta charset="UTF-8"></meta>
        <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600,600italic,700,800,700italic,800italic|Open+Sans+Condensed:300,700,300italic&subset=latin,latin-ext,cyrillic-ext,cyrillic' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="css/korisnik.css" />
        <script src="https://code.jquery.com/jquery-3.1.0.js" integrity="sha256-slogkvB1K3VOkzAI8QITxV3VzpOnkeNVsKvtkYLMjfk=" crossorigin="anonymous"></script>
        <script type="text/javascript" src="js/easypiechart.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.6/Chart.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.15/angular-ui-router.js"></script>
        <script src="app.js"></script>
        <script src="controllers/loginController.js"></script>
    </head>

    <body>

        <div ui-view></div>

    </body>
</html>

controller:

app.controller("LoginController", function($scope, $http){

})

template is saved in views/login.html

2
  • <meta> is a self-closing tag. Don't know if that's the problem but you never know. Also, check your console Network tab to make sure all the scripts are being loaded. Is there any content in views/login.html? Commented Jul 15, 2016 at 2:19
  • Ty for that answer, i changed my meta tag, also inspected network tab an all scripts are loaded. Template file contains login form. Commented Jul 15, 2016 at 2:26

1 Answer 1

1

To use the root path, the state config url property should be an empty string, not '/'.

$stateProvider.state("Login", {
  url: "",
  controller: "LoginController",
  templateUrl: "views/login.html"
});

http://plnkr.co/edit/Iypm5fXgpcrLS7Smlc62?p=preview

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot your solution worked. You saved my day!

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.