I started learning AngularJS and trying to make a very simple skeleton application with multiple views. I am using Flask for the back-end.
Problem: When I load the page it does not show the appropriate view - I get a blank page.
The relevant folder structure is like this:
app/
| static/
| | js/
| | | app.js
| | | controllers.js
| | partials/
| | | landing.html
| templates/
| | index.html
| views/
| | views.py
Basically my index.html looks like this:
<!DOCTYPE html>
<html>
<head lang="en" ng-app="MyApp">
<meta charset="UTF-8">
<title>My App</title>
<link href="{{ url_for('static', filename='semantic/semantic.min.css') }}" rel="stylesheet" type="text/css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-route.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-resource.min.js"></script>
<script src="{{ url_for('static', filename='semantic/semantic.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/app.js') }}"></script>
<script src="{{ url_for('static', filename='js/controllers.js') }}"></script>
</head>
<body>
<div id="content" ng-view></div>
</body>
</html>
My python index function:
@app.route('/')
@app.route('/index')
def index():
return make_response(render_template('index.html'))
My 'app.js':
'use strict';
angular.module('MyApp', ['ngRoute'])
.config(['$routeProvider', '$locationProvider',
function ($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: 'static/partials/landing.html',
controller: IndexController
})
.otherwise({
redirectTo: '/'
});
$locationProvider.html5Mode(true);
}]);
And my IndexController in controllers.js which does nothing:
'use strict';
/* Controllers */
function IndexController($scope) {
}
The landing.html file simply contains some text.
Where am I going wrong with this? All I get is an empty page. I noticed it does not complain or throw any errors if I put any path in templateUrl: path/to/landing.html, so I am not sure this is the correct way reference these files. Is it possible to somehow use the flask url_for function here?
EDIT
I tried using a template directly instead of a template URL. So I have
.....
.when('/', {
template: 'Hello',
controller: IndexController
})
....
This is still giving me a blank page.