I am trying to get my Angular-Flask App to render partial HTML files in a base html file. The application loads the base html (Window Title and Footer load) but nothing loads for the ng-view. Perhaps my angular routing to the partials is not correct?
File Structure
->flaskapp
->static
->js
->appController.js
->routing.js
->homeController.js
...
->views
->home
->__init__.py
...
->templates
->partials
->home.html
...
->base.html
home
mod = Blueprint('home', __name__)
@mod.route('/')
def index():
return render_template('main.html')
base.html
<!DOCTYPE html>
<html ng-app="FlaskApp">
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-route.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-resource.min.js"></script>
<script src=/static/js/appController.js></script>
<script src=/static/js/homeController.js></script>
<script src=/static/js/bootstrap.js></script>
{% block head %}
<meta charset="UTF-8">
<title>{% block title %}{% endblock %} - Flask POC</title>
{% endblock %}
</head>
<body>
<div ng-controller="AppController">
<div ng-view>
</div>
<br />
<div id="footer">
{% block footer %}
© Copyright 2014
{% endblock %}
</div>
</body>
</html>
home.html
<p>Just some Random Text</p>
appController.js
'use strict';
var app = angular.module('FlaskApp', ['ngRoute']);
app.controller('AppController', function($scope){
});
homeController.js
'use strict';
var app = angular.module('FlaskApp');
app.controller('HomeController', function(){
});
routing.js
'use strict';
var app = angular.module('FlaskApp');
app.config(function($routeProvider){
$routeProvider.when('/', {
templateURL: 'partials/home.html',
controller: 'HomeController'
}).otherwise({ redirectTo: '/' });
});
Does anyone know why I cant get partials to load? Thanks a lot.
Attempts
- Changed templateURL to:
- /partials/home.html
- ../partials/home.html
- static/partials/home.html
- /static/partials/home.html
- ../static/partials/home.html
If it helps, here is the link of the tutorial I have been following: http://blog.pangyanhan.com/posts/2013-08-27-ngtut.html
- Moved base.html into the static folder