AngularJS performs an OPTIONS HTTP request for a cross-origin resource

OPTIONS request are by no means an AngularJS bug, this is how Cross-Origin Resource Sharing standard mandates browsers to behave. Please refer to this document: https://developer.mozilla.org/en-US/docs/HTTP_access_control, where in the “Overview” section it says: The Cross-Origin Resource Sharing standard works by adding new HTTP headers that allow servers to describe the set of origins that are … Read more

Request header field Access-Control-Allow-Headers is not allowed by Access-Control-Allow-Headers

I had the same problem. In the jQuery documentation I found: For cross-domain requests, setting the content type to anything other than application/x-www-form-urlencoded, multipart/form-data, or text/plain will trigger the browser to send a preflight OPTIONS request to the server. So though the server allows cross origin request but does not allow Access-Control-Allow-Headers , it will … Read more

With ng-bind-html-unsafe removed, how do I inject HTML?

Instead of declaring a function in your scope, as suggested by Alex, you can convert it to a simple filter : angular.module(‘myApp’) .filter(‘to_trusted’, [‘$sce’, function($sce){ return function(text) { return $sce.trustAsHtml(text); }; }]); Then you can use it like this : <div ng-bind-html=”preview_data.preview.embed.html | to_trusted”></div> And here is a working example : http://jsfiddle.net/leeroy/6j4Lg/1/

Changing route doesn’t scroll to top in the new page

The problem is that your ngView retains the scroll position when it loads a new view. You can instruct $anchorScroll to “scroll the viewport after the view is updated” (the docs are a bit vague, but scrolling here means scrolling to the top of the new view). The solution is to add autoscroll=”true” to your … Read more

‘Best’ practice for restful POST response

Returning the new object fits with the REST principle of “Uniform Interface – Manipulation of resources through representations.” The complete object is the representation of the new state of the object that was created. There is a really excellent reference for API design, here: Best Practices for Designing a Pragmatic RESTful API It includes an … Read more

How to add custom validation to an AngularJS form?

Edit: added information about ngMessages (>= 1.3.X) below. Standard form validation messages (1.0.X and above) Since this is one of the top results if you Google “Angular Form Validation”, currently, I want to add another answer to this for anyone coming in from there. There’s a method in FormController.$setValidity but that doesn’t look like a … Read more

Ng-model does not update controller value

“If you use ng-model, you have to have a dot in there.” Make your model point to an object.property and you’ll be good to go. Controller $scope.formData = {}; $scope.check = function () { console.log($scope.formData.searchText.$modelValue); //works } Template <input ng-model=”formData.searchText”/> <button ng-click=”check()”>Check!</button> This happens when child scopes are in play – like child routes or … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)