I have an existing Django project and am adding a new app which consists of an API (using the rest-framework) and an angular app. This app contains one Django template, which simply serves as a way for Angular to hook in, and then work with it's own partials:
{% extends "base.html" %}
{% block content %}
<div ui-view></div>
{% endblock %}
From here, I would like for angular to take over the routing of the application:
$resourceProvider.defaults.stripTrailingSlashes = false;
// Routing
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
$stateProvider
.state('list', {
url: '/routines',
templateUrl: 'static/partials/routine/routine_list.html',
controller: 'RoutineListController',
})
.state('add', {
url: '/routines/add',
templateUrl: 'static/partials/routine/routine_add_edit.html',
controller: 'RoutineAddController',
});
$urlRouterProvider.otherwise('/routines');
This works fine for the first page the app loads, however attempting to navigate to any subsequent page results in Django displaying a 404 error message
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/routines/add
Based on my current (limited) knowledge of both systems, I attempted to specify a url in my Django config that would apply to all routine/* urls and not load a template, allowing angular to request the partial it requires so it can continue running the SPA uninterrupted. However, I was unable to find any information on specifying a URL without a template, leading me to believe that this is not the correct solution.
urlpatterns = [
url(r'^$', views.routineView, name='routine'),
url(r'^/.*$', views.routineView, name='angular'),
Summary: I would like to use Angular and a Django rest API app to create a web application. However, I would like to keep the rest of my existing Django site and simply add this on (an embedded SPA in my current Django base.html template). How do I set up the routing (on both Angular and Django) so that Django allows Angular to run interrupted once a certain page has been requested (in this case site.com/routines).
I'm just a beginner I want to create button for remove clone but I can't. This is my code but it isn't work. Please help me to know where did I wrong. PS. Sorry for my poor English HTML <div ...
I'm just a beginner I want to create button for remove clone but I can't. This is my code but it isn't work. Please help me to know where did I wrong. PS. Sorry for my poor English HTML <div ...
I have a 'Phone Number' field in my web form. I also have a 'hidden' form field which contains a unicode phone icon [☎]. Entering a phone number is optional for my site visitors. So... if ...
I have a 'Phone Number' field in my web form. I also have a 'hidden' form field which contains a unicode phone icon [☎]. Entering a phone number is optional for my site visitors. So... if ...
If I have something like this: class MyComponent { constructor() { this.interval = Observbale.interval(1000); } } const c = new MyComponent(); const subscription = c.interval.subscribe(() ...
If I have something like this: class MyComponent { constructor() { this.interval = Observbale.interval(1000); } } const c = new MyComponent(); const subscription = c.interval.subscribe(() ...
I have an array which is binded by reference as a model (to handsontable). Let's call it data. At some point I need to recalc it from scratch (let's call a calced new array freshData; it may have a ...
I have an array which is binded by reference as a model (to handsontable). Let's call it data. At some point I need to recalc it from scratch (let's call a calced new array freshData; it may have a ...