Promise found in the expression. Automatic unwrapping of promises in Angular expressions is deprecated-Collection of common programming errors
I’m trying to create a new AngularJS project, but I get some errors 🙁
This is my app and controller;
var app = angular.module('myApp', ['localytics.directives'])
.config(['$parseProvider', function ($parseProvider) {
return $parseProvider.unwrapPromises(true);
}])
.controller('myController', function ($scope, $http, $q, $timeout) {
var simulateAjax;
simulateAjax = function (result) {
var deferred, fn;
deferred = $q.defer();
fn = function () {
return deferred.resolve(result);
};
$timeout(fn, 1000);
return deferred.promise;
};
$scope.ListOfTags = function () {
$http({
method: 'Post',
url: 'FillCategories'
}).success(function (data, status, headers, config) {
$scope.optionsFromQuery = (function () {
return simulateAjax(data);
})();
}).error(function (data, status, headers, config) {
$scope.message = 'Unexpected Error';
});
}
$scope.directiveOptions = {
no_results_text: "Error"
};
});
Im using Chosen.js as follows:
Select
When I try to get categories it is working but the following exception is thrown (which breaks the Angular app):
[$parse] Promise found in the expression
optionsFromQuery
. Automatic unwrapping of promises in Angular expressions is deprecated.
On a second attempt to get the categories nothing seems to work.
What is causing this?