0

I'm new to JS, and am trying out a simple Angular ui-router example, but I can't seem to get the router working, and can't see why. I've tested a few examples to make sure angular has been loaded and custom.js has been loaded (which they are), but when I come to using the router I get nothing, from my little knowledge I can't see anything glaringly obvious (this is basically and copy and paste example).

--HTML---

<!DOCTYPE html>
<html ng-app = "routerApp">
<head>
    <title></title>
    <script src="js/angularmin.js"></script>
    <script src="js/custom.js"></script>
</head>
<body>
TEST APP
<div ui-view></div>


</body>
</html>

--js/custom.js--

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

routerApp.config(function($stateProvider, $urlRouterProvider) {
    $urlRouterProvider.otherwise('/home');
    $stateProvider

        // HOME STATES AND NESTED VIEWS ========================================
        .state('home', {
            url: '/home',
            templateUrl: 'home-partial.html'
        })

        // ABOUT PAGE AND MULTIPLE NAMED VIEWS =================================
        .state('about', {
            // we'll get to this in a bit       
        });

});
1
  • Please check the console Commented Sep 5, 2016 at 18:19

1 Answer 1

1

You have not referenced the js file for ui-router,

<head>
    <title></title>
    <script src="js/angularmin.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.18/angular-ui-router.js" > </script>
    <script src="js/custom.js"></script>
</head>

DEMO APP

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

7 Comments

does that need to be downloaded separately?
@SamPalmer yes indeed
ah I thought it was part of the original angular code, so I just used bower to download it, and include "angular-ui-router.js", but still no result
@SamPalmer did you check the sample app?
so I need to build the angular-ui-router after using bower? As I can't see angular-ui-router.js anywhere
|

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.