【发布时间】:2014-06-12 15:40:07
【问题描述】:
我正在使用带有 Angular 的 Django,
在我的角度范围内,我有:
$scope.templates = [
{ name: 'addSongTemplateAjax', url: "templates/add_song_for_ajax.html"},
{ name: '', url: ''}
];
$scope.template = $scope.templates[0];
在我的 html 文件中:
<div class = "add_song_submit_form" ng-include="template.url">
</div>
所以,我想从 javascript 角度加载模板 add_song_for_ajax.html。这是行不通的。 Django 给我一个错误 404。我知道这是逻辑,因为我们试图在 urls.py 中找到 url ...
所以我确信我必须处理我的应用程序的设置和 urls.py 才能对 django 说,是的,客户端可以加载这个文件!但我不知道怎么做。
我要加载的 template.html
<div class="alert alert-info" style = "margin-bottom:10px!important; margin-top:10px;">The song will be added to the playlist selected <strong>//playlist_selected.fields.name//</strong></div>
<form role = "form">
<div class="form-group">
<label for = "artist_band">Artist / Band</label>
<input class="form-control" id="artist_band" placeholder = "Enter artist / band">
</div>
<div class="form-group">
<label for="Title">Title / Song name</label>
<input type="text" class="form-control" id="title" placeholder="Title / Song name">
</div>
<div class="form-group">
<label for = "url">Url</label>
<input class="form-control" id="url" placeholder = "Url">
</div>
<button type="submit" class="btn btn-default" ng-click = "submit_add_song()">Submit</button>
</form>
有什么想法吗?
【问题讨论】:
标签: javascript python django angularjs