<commit_before>.. _reverse-urls:

================================
Manage Django URLs for AngularJS
================================

You may have noticed, that AngularJS controllers sometimes need a URL pointing to a Django view of
your application. Do not enter into temptation to hard code such a URL into the client side
controller code. Nor enter into temptation to create Javascript dynamically using a template
engine. There is a clean and simple solution to solve this problem.

.. note:: With version 0.8 **django-angular** introduced a new way to handle urls. Documentation for now deprecated
          approach is available :ref:`here <manage-urls>`.

Installation
============

Django settings
---------------

1. Add ``'djangular.middlewares.DjangularUrlMiddleware'`` to ``MIDDLEWARE_CLASSES`` in django settings

.. warning:: This must be the first middleware included in ``MIDDLEWARE_CLASSES``

2. Include ``django-angular`` urls into the root url configuration

.. code-block:: python

    urlpatterns = patterns('',
        url(r'^djangular/', include('djangular.urls', namespace='djangular')),
        # Other urls
    )

Angular
-------

1. Include ``django-angular.js``:

.. code-block:: html

    <script src="{% static 'djangular/js/django-angular.js' %}"></script>

2. Add ``ng.django.urls`` as a dependency for you app:

.. code-block:: html

    <script>
        var my_app = angular.module('MyApp', ['ng.django.urls', /* other dependencies */]);
    </script>

The ``djangoUrl`` service is now available through `dependency injection`_
to all directives and controllers.

Usage
=====<commit_msg>updated docs, removed urlconf entry paragraph<commit_after>.. _reverse-urls:

================================
Manage Django URLs for AngularJS
================================

You may have noticed, that AngularJS controllers sometimes need a URL pointing to a Django view of
your application. Do not enter into temptation to hard code such a URL into the client side
controller code. Nor enter into temptation to create Javascript dynamically using a template
engine. There is a clean and simple solution to solve this problem.

.. note:: With version 0.8 **django-angular** introduced a new way to handle urls. Documentation for now deprecated
          approach is available :ref:`here <manage-urls>`.

Installation
============

Django settings
---------------

* Add ``'djangular.middlewares.DjangularUrlMiddleware'`` to ``MIDDLEWARE_CLASSES`` in django settings

.. code-block:: python

    MIDDLEWARE_CLASSES = (
        'djangular.middlewares.DjangularUrlMiddleware',
        # Other middlewares
    )

.. warning:: This must be the first middleware included in ``MIDDLEWARE_CLASSES``


Angular
-------

* Include ``django-angular.js``:

.. code-block:: html

    <script src="{% static 'djangular/js/django-angular.js' %}"></script>

* Add ``ng.django.urls`` as a dependency for you app:

.. code-block:: html

    <script>
        var my_app = angular.module('MyApp', ['ng.django.urls', /* other dependencies */]);
    </script>

The ``djangoUrl`` service is now available through `dependency injection`_
to all directives and controllers.

Usage
=====
{'fraction_non_alphanumeric': 0.16017587939698494, 'fraction_numerical': 0.002512562814070352, 'mean_word_length': 3.8700305810397553, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2809744', 'n_tokens_mistral': 903, 'n_tokens_neox': 841, 'n_words': 332}