Django Rest Framework + AngularJS: Correct way for CSRF Protection?

Without Django Rest Framework, I used to create forms / POST requests like so: <form id=loginForm method=post action=register>{% csrf_token %} <form> but I stared using Django Rest Framework and AngularJS on the frontend and I wasnt sure how to use the CSRF token, so I decided to do some research. I came across this […]

How to test values on scope of directive with inline controller

I have the following directive which I want to unit test: use strict; angular.module(gameApp) .directive(gmGravatar, gmGravatar); gmGravatar.$inject = $routeParams, playersService; function gmGravatar() { var directive = { restrict: E, template: <img gravatar-src=gravatar.email alt= id=gravatar class=img-rounded style=margin: auto; display: block;>, controller: function($routeParams, playersService) { var vm = this; var playerId = $routeParams.playerId; playersService.getPlayerInfo({ playerId: playerId }).$promise.then(function(player) […]

Using gulp-angular-templatecache to combine HTML into template.js, getting $injector Module Unavailable error

Im using gulp-angular-templatecache, to grab all my partial HTML template files and combined them into 1 template.js file. The first part I was able to complete, I can run my Gulp task and it creates templatestemplates.js . templates.js: angular.module(templates).run($templateCache, function($templateCache) {$templateCache.put(beta.html,<div class=\login-container\ ng-controller=\BetaCtrl as beta\>\n <section class=\login-form-block\>\n <header>\n <div class=\tickertags-logo-big\><div>\n <h1>Welcome to the TickerTags beta! […]

Method Post with json Angular js

I have problems in my request, the server wait: *POST workv1chats HTTP1.1 X-Client-Instance: clienteinstance Content-Type: multipartform-data; boundary=32366fff-0f80-474c-a809-14e6ffaacca1 Content-Length: 352 User-Agent: Dalvik2.1.0 (Linux; U; Android 5.0.2; XT1033 BuildLXB22.46-28) Host: XXXXXX Connection: Keep-Alive Accept-Encoding: gzip 32366fff-0f80-474c-a809-14e6ffaacca1 Content-Disposition: form-data; name=message-body Content-Type: applicationjson; charset=utf-8 Content-Length: 110 Content-Transfer-Encoding: binary {attachment:,content:Test,localAddress:XXXXXX,receiver:XXXXX} 32366fff-0f80-474c-a809-14e6ffaacca1* 500 Internal Server Error Connection: keep-alive X-Powered-By: Undertow1 Server: […]

Relative links in AngularJS

In my templates I want to use relative routes. Currently I have absolute paths in my anchor href s, which is suboptimal <a href=#dashboardsettings>Settings<a> How can I rewrite this to be a relative navigation (in this relative to dashboard )? It should work with hashbang and html5 history api routes (whichever AngularJS uses or falls […]

Triggering an animation in angular JS on number increment?

I have a div with a bound variable: <i class=fa fa-check><i> {{packages.limit}} Packages received I have a function in my controller that, among other things, increments limit _this.limit = 5; _this.addPackage = function() { _this.limit++; }; The net result here is that the number increments on a click. Id like to call dramatic attention […]

How to apply Multiple ng-pattern with one input control

I am trying to Validate Postal code and Phone Number in Text box using Angularjs. But its not working <input type=text class=form-control errorfields id=postalCode name=postalCode ng-model=postalCode ng-pattern=(^(\d{5}(-\d{4})?|A-CEGHJ-NPRSTVXY\dA-CEGHJ-NPRSTV-Z ?\dA-CEGHJ-NPRSTV-Z\d)$)||(^0-9) required> View More Answer And Comment : Stackoverflow See this answer: Angularjs dynamic ng-pattern validation You can add a function from scope that returns a true or false […]

How can I reload once using window.location.reload?

Im using AngularJs for my web application and I got problems with my login, the only solution that I found is reloading the page after login, but I need only once, but now is an infinite loop. How can I use Window.location.reload() only once Login Method: .success(function (data) { $scope.tokengenerated = data.token; $cookies.put(Username, UsernameValue); $cookies.put(Token, […]