当前位置: 动力学知识库 > 问答 > 编程问答 >

angularjs - Django and Angular routing

问题描述:

We are using Django as backend and Angular as front end and templating. I am doing the front end part.

When I designed the UI the url was

xxx/dashboard.html#/

but while intergeating I get

xxx/dashboard/#/

so whats the difference.

Also my routeprovider in Angular is throwing 404 error

$routeProvider

.when('/', {

templateUrl: 'pages/dash_home.html',

controller: 'dashController'

})

My Html

<!doctype html>

{% load staticfiles %}

<html class="no-js" lang="en">

<head>

....

</head>

<body ng-app="gb_dash">

{% block content %}

<div class="fullWidth">

<div ng-view>...

My app structure

>apps

>deployment

...

...

>static

>bower_components

...

...

>js

dash.js //angular_app

>templates

>pages

dash_home.html

dashboard.html

I am getting error

GET http://127.0.0.1:8000/static/templates/pages/dash_home.html 404 (NOT FOUND)

Where am i mistaking. I tried html5mode, then no error showing but still the template didnt load. Or is there backend mistake?

网友答案:

It would be helpful if you use

xxx/dashboard.html#/

then in the route provider

$routeProvider
.when('/', {
    templateUrl: '#/pages/dash_home.html',
    controller: 'dashController'
})

It will look for the # and then attach the url with it.

分享给朋友:
您可能感兴趣的文章:
随机阅读: