I have the following structure and code :
project/
app.py
templates/
/index.html
static/
/angular.js
index.html
<!doctype html>
<html ng-app="myApp">
<head>
<meta charset="utf-8"/>
<title>My App</title>
</head>
<body ng-controller="myCtrl as ctrl">
<div>
{{ctrl.foo}}
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.js"></script>
<script type="text/javascript">
angular.module('myApp', [])
.controller('myCtrl', [function () {
var self = this;
self.foo = 10;
}]);
</script>
</body>
</html>
and app.py
from flask import Flask
app = Flask(__name__)
from flask import render_template
@app.route('/')
def hello_world():
return render_template('index.html')
if __name__ == '__main__':
app.run(debug=True)
Whatever I do, I still have the following error : UndefinedError: 'ctrl' is undefined
which I guess is due to the fact that Flask does not load the angular.js
I also tried with the static path
<script type=text/javascript src="{{url_for('static', filename='angular.js')}}"></script>
and
<script type=text/javascript src="../static/angular.js"></script>
But still no sucess... Any ideas ?