I've been scouring the web for answers to this particular question, and am surprised I haven't found much on this issue. I have a Django site I am redoing to use Angular for the front-end and Django for the back-end, which seems to be a common practice. However, none of the examples I have found deal with the issue of the static path changing in production. I have an S3 bucket in production. Therefore using the path static/whatever/maybesomecss/oranimage
is not going to work for partials or in trying to get using $resource some data I store in a .json file.
Here is some code to illustrate what I am talking about.
.state('math', {
url: '/math',
templateUrl: 'games/math',
controller: 'MathController'
})
.state('secretgame', {
url:'/secretgame',
templateUrl: 'static/js/games/Partials/secretgame.html',
controller: 'secretController'
})
In the above,games/math works if there is a Django URL for it to hit. But I don't want people to be able to go to it directly, it gets messed up (which is a separate question), and anyways I would rather use partials here. 'secretgame' works, but that templateUrl is not going to work in production. Because of the S3 bucket replacing 'static', basically.
One solution would be to stick the STATIC_URL setting I use normally into a global javascript variable and then have something like templateUrl: staticUrl + js/games/partials/secretgame.html
, but that doesn't seem great.
Has anyone dealt with this issue? Let me know if there is other information I should provide.
Just to clarify: with partials, separating Django templating from AngularJS's using {% verbatim %} isn't going to work. That's fine for stuff you load from Django URL, but not for a partial, which is consumed entirely by AngularJS.