nycynik
nycynik

Reputation: 7541

Angular JS routes not working, only shows path to partial, not partial

I am following a tutorial on AngularJS - "Building a website with AngularJS"

The routes I am using are pretty much the same as the tutorial :

// JavaScript Document
angular.module('quest', []).
    config(function($routeProvider) {
        $routeProvider.
            when('/about', {template:'partials/about.html'}).
            when('/start', {template:'partials/start.html'}).
            otherwise({redirectTo:'/home', template:'partials/home.html'});
    });

The problem is: it only shows the path to the resource, instead of the contents of the resource, so instead of showing the html content, it just shows:

PARTIALS/ABOUT.HTML

I am not sure what I am doing wrong, but it does work, if i go to the #/about URL it shows "PARTIALS/ABOUT.HTML" if i change the url to index.html#/start it shows "PARTIALS/START.HTML"

html of page:

<!DOCTYPE html>
<html lang="en" ng-app="quest">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
        <link rel="stylesheet" type="text/css" href="css/index.css" />
        <title></title>
    </head>
    <body ng-controller="MainController">
        <script type="text/javascript" src="js/angular.min.js"></script>
        <script type="text/javascript" src="js/quest.js"></script>

        <div ng-view></div>

    </body>
</html>

Upvotes: 5

Views: 2470

Answers (1)

holographic-principle
holographic-principle

Reputation: 19738

Use templateUrl instead of template

Upvotes: 11

Related Questions