{"id":7296,"date":"2014-06-04T04:20:58","date_gmt":"2014-06-04T04:20:58","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/06\/04\/promise-found-in-the-expression-automatic-unwrapping-of-promises-in-angular-expressions-is-deprecated-collection-of-common-programming-errors-2\/"},"modified":"2014-06-04T04:20:58","modified_gmt":"2014-06-04T04:20:58","slug":"promise-found-in-the-expression-automatic-unwrapping-of-promises-in-angular-expressions-is-deprecated-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/06\/04\/promise-found-in-the-expression-automatic-unwrapping-of-promises-in-angular-expressions-is-deprecated-collection-of-common-programming-errors-2\/","title":{"rendered":"Promise found in the expression. Automatic unwrapping of promises in Angular expressions is deprecated-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m trying to create a new AngularJS project, but I get some errors \ud83d\ude41<\/p>\n<p>This is my app and controller;<\/p>\n<pre><code>var app = angular.module('myApp', ['localytics.directives'])\n    .config(['$parseProvider', function ($parseProvider) {\n        return $parseProvider.unwrapPromises(true);\n    }])\n    .controller('myController', function ($scope, $http, $q, $timeout) {\n    var simulateAjax;\n    simulateAjax = function (result) {\n        var deferred, fn;\n        deferred = $q.defer();\n        fn = function () {\n            return deferred.resolve(result);\n        };\n        $timeout(fn, 1000);\n        return deferred.promise;\n    };\n\n    $scope.ListOfTags = function () {\n        $http({\n            method: 'Post',\n            url: 'FillCategories'\n        }).success(function (data, status, headers, config) {\n            $scope.optionsFromQuery = (function () {\n                return simulateAjax(data);\n            })();\n        }).error(function (data, status, headers, config) {\n            $scope.message = 'Unexpected Error';\n        });\n    }\n    $scope.directiveOptions = {\n        no_results_text: \"Error\"\n    };\n});\n<\/code><\/pre>\n<pre><code>\n<\/code><\/pre>\n<p>Im using Chosen.js as follows:<\/p>\n<pre><code>\n    Select\n\n<\/code><\/pre>\n<p>When I try to get categories it is working but the following exception is thrown (which breaks the Angular app):<\/p>\n<blockquote>\n<p>[$parse] Promise found in the expression <code>optionsFromQuery<\/code>. Automatic unwrapping of promises in Angular expressions is deprecated.<\/p>\n<\/blockquote>\n<p>On a second attempt to get the categories nothing seems to work.<\/p>\n<p>What is causing this?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m trying to create a new AngularJS project, but I get some errors \ud83d\ude41 This is my app and controller; var app = angular.module(&#8216;myApp&#8217;, [&#8216;localytics.directives&#8217;]) .config([&#8216;$parseProvider&#8217;, function ($parseProvider) { return $parseProvider.unwrapPromises(true); }]) .controller(&#8216;myController&#8217;, function ($scope, $http, $q, $timeout) { var simulateAjax; simulateAjax = function (result) { var deferred, fn; deferred = $q.defer(); fn = function [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7296","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7296","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7296"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7296\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}