E
E
Egor Trubnikov-Panov2015-06-25 07:32:09
JavaScript
Egor Trubnikov-Panov, 2015-06-25 07:32:09

How to use Angular under Django?

$scope.details.pics = [{
                                        picture: '/media/OrderPicture/130/15480__e1a4d2fc26070b832cf0e1a59f70a9bd.jpg',
                                        thumbnail: '/media/cache/e5/98/e5989c3a9ed2520ead1bb8b8558774ba.jpg'
                                    },
                                        {
                                            picture: 'http://www.kartoshka.com/sites/default/files/kk4.jpg',
                                            thumbnail: 'http://www.kartoshka.com/sites/default/files/kk4.jpg'
                                        }];

<li ng-repeat="pic in details.pics">
                        <a ng-href="pic.picture" ><img ng-src="pic.thumbnail"/></a>
                        <a ng-href="pic.picture" ><span class="ui-icons icons-attached-file h-m-r"></span></a>
                    </li>

Why doesn't angular put down attributes?
if you set it in {{}}, then python will take over
if you do something like this:
<li ng-repeat="pic in details.pics" ng-class="pic.picture"></li>

then everything will work fine. But this is not what is needed.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
U
un1t, 2015-06-25
@un1t

https://docs.djangoproject.com/en/1.8/ref/template...

A
Anton, 2015-06-25
@sHinE

I do not know about jango, but in twig, where the same brackets are used in the server-side template engine, there is such a solution
. output brackets for angular as a string

V
v- death, 2015-11-24
@vGrabko99

I have a bomb.
I didn’t even know the python, after googling for 15 seconds I understood.
The Django template language syntax uses four constructs.
Variables are separated by {{ and }}, for example:
For context {'first_name': 'John', 'last_name': 'Doe'}, the template renders:
Dictionary keys, object attributes, and list elements are accessed through a dot:

{{ my_dict.key }}
{{ my_object.attribute }}
{{ my_list.0 }}

cerf ,kzlm 'nj t,fyyst gbpltw/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question