{"action":"created","issue":{"url":"https://api.github.com/repos/angular/material/issues/2462","labels_url":"https://api.github.com/repos/angular/material/issues/2462/labels{/name}","comments_url":"https://api.github.com/repos/angular/material/issues/2462/comments","events_url":"https://api.github.com/repos/angular/material/issues/2462/events","html_url":"https://github.com/angular/material/issues/2462","id":69909555,"number":2462,"title":"md-autocomplete: Support `md-item-text` evals as promises","user":{"login":"epelc","id":5204642,"avatar_url":"https://avatars.githubusercontent.com/u/5204642?v=3","gravatar_id":"","url":"https://api.github.com/users/epelc","html_url":"https://github.com/epelc","followers_url":"https://api.github.com/users/epelc/followers","following_url":"https://api.github.com/users/epelc/following{/other_user}","gists_url":"https://api.github.com/users/epelc/gists{/gist_id}","starred_url":"https://api.github.com/users/epelc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/epelc/subscriptions","organizations_url":"https://api.github.com/users/epelc/orgs","repos_url":"https://api.github.com/users/epelc/repos","events_url":"https://api.github.com/users/epelc/events{/privacy}","received_events_url":"https://api.github.com/users/epelc/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular/material/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"ThomasBurleson","id":210413,"avatar_url":"https://avatars.githubusercontent.com/u/210413?v=3","gravatar_id":"","url":"https://api.github.com/users/ThomasBurleson","html_url":"https://github.com/ThomasBurleson","followers_url":"https://api.github.com/users/ThomasBurleson/followers","following_url":"https://api.github.com/users/ThomasBurleson/following{/other_user}","gists_url":"https://api.github.com/users/ThomasBurleson/gists{/gist_id}","starred_url":"https://api.github.com/users/ThomasBurleson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThomasBurleson/subscriptions","organizations_url":"https://api.github.com/users/ThomasBurleson/orgs","repos_url":"https://api.github.com/users/ThomasBurleson/repos","events_url":"https://api.github.com/users/ThomasBurleson/events{/privacy}","received_events_url":"https://api.github.com/users/ThomasBurleson/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/angular/material/milestones/10","html_url":"https://github.com/angular/material/milestones/0.9.0","labels_url":"https://api.github.com/repos/angular/material/milestones/10/labels","id":863796,"number":10,"title":"0.9.0","description":"## Goals\r\n\r\nThis is  **polishing** milestone to address many of the existing bugs, validate layouts and browser/device compatibility, and improve performance.","creator":{"login":"ThomasBurleson","id":210413,"avatar_url":"https://avatars.githubusercontent.com/u/210413?v=3","gravatar_id":"","url":"https://api.github.com/users/ThomasBurleson","html_url":"https://github.com/ThomasBurleson","followers_url":"https://api.github.com/users/ThomasBurleson/followers","following_url":"https://api.github.com/users/ThomasBurleson/following{/other_user}","gists_url":"https://api.github.com/users/ThomasBurleson/gists{/gist_id}","starred_url":"https://api.github.com/users/ThomasBurleson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThomasBurleson/subscriptions","organizations_url":"https://api.github.com/users/ThomasBurleson/orgs","repos_url":"https://api.github.com/users/ThomasBurleson/repos","events_url":"https://api.github.com/users/ThomasBurleson/events{/privacy}","received_events_url":"https://api.github.com/users/ThomasBurleson/received_events","type":"User","site_admin":false},"open_issues":28,"closed_issues":388,"state":"open","created_at":"2014-11-12T18:26:48Z","updated_at":"2015-04-24T17:20:18Z","due_on":"2015-04-27T05:00:00Z","closed_at":null},"comments":7,"created_at":"2015-04-21T17:45:27Z","updated_at":"2015-04-24T17:32:56Z","closed_at":null,"body":"Right now using `md-item-text` with a promise shows `[Object object]` instead of what it resolves too. I couldn't find a way to get it too work with a promise so perhaps `md-autocomplete` could check if it's a promise and if so wait for it to resolve.\r\n\r\nPlease let me know if I can get around this some other way."},"comment":{"url":"https://api.github.com/repos/angular/material/issues/comments/96008013","html_url":"https://github.com/angular/material/issues/2462#issuecomment-96008013","issue_url":"https://api.github.com/repos/angular/material/issues/2462","id":96008013,"user":{"login":"epelc","id":5204642,"avatar_url":"https://avatars.githubusercontent.com/u/5204642?v=3","gravatar_id":"","url":"https://api.github.com/users/epelc","html_url":"https://github.com/epelc","followers_url":"https://api.github.com/users/epelc/followers","following_url":"https://api.github.com/users/epelc/following{/other_user}","gists_url":"https://api.github.com/users/epelc/gists{/gist_id}","starred_url":"https://api.github.com/users/epelc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/epelc/subscriptions","organizations_url":"https://api.github.com/users/epelc/orgs","repos_url":"https://api.github.com/users/epelc/repos","events_url":"https://api.github.com/users/epelc/events{/privacy}","received_events_url":"https://api.github.com/users/epelc/received_events","type":"User","site_admin":false},"created_at":"2015-04-24T17:32:56Z","updated_at":"2015-04-24T17:32:56Z","body":"@ThomasBurleson I found a work around!\r\n\r\nI really wanted to fix this but I found a workaround which is even better! Instead of using a promise with `md-item-text` you can use `md-selected-item-change=\"selectItem(item)` check if it's not null and then run your promise and use `angular.extend()` to copy your results to whatever model you use with `md-selected-item`.\r\n\r\nExample markup\r\n```\r\n<md-autocomplete md-selected-item=\"Address.Address\" md-search-text=\"addrSearchText\" md-items=\"place in Maps.SearchForAddress(addrSearchText)\" md-selected-item-change=\"selectedItem(place)\" md-item-text=\"place.description || Address.Address\" md-delay=\"200\" md-floating-label=\"Address\">\r\n        <span md-highlight-text=\"addrSearchText\" ng-bind=\"place.description\"></span>\r\n    </md-autocomplete>\r\n//Below you have inputs for the zipcode city state etc\r\n```\r\n\r\nExample code\r\n```\r\n$scope.fmtPlace = function(place) {\r\n    var deferred = $q.defer()\r\n    //Sometimes place will be empty\r\n    if (place) {\r\n        //Call your func to fill in the data which returns a promise\r\n        Maps.RawGeocode(place.description).then(function(loc) {\r\n            deferred.resolve(loc)\r\n        }, function(error) {\r\n            deferred.reject(error)\r\n        })\r\n    } else {\r\n        //This won't be nesecary after we fix the TODO in selectedItem()\r\n        deferred.reject()\r\n    }\r\n\r\n    return deferred.promise\r\n}\r\n\r\n$scope.selectedItem = function(place) {\r\n    //Note when you first focus on the autocomplete input place == null\r\n    console.log('Selected an item:', $scope.Address.Address)\r\n    if ($scope.Address.Address != null) {\r\n        // Call your promise here\r\n        // TODO possibly check if $scope.Address.Address is equal to what you just set it to.\r\n        // So we can avoid the ocasional autocomplete menu popup after we set it\r\n        $scope.fmtPlace(place).then(function(addr) {\r\n            angular.extend($scope.Address, addr)\r\n        })\r\n    }\r\n}\r\n```\r\n\r\nPlease note in my example `$scope.Address.Address` is the address line the rest of the `$scope.Address` object contains things like city,state,country etc but the layout is really probably specific to your app.\r\n\r\n@ThomasBurleson Anyways the above works perfectly for my use case and I think it will work for anyone else who needs a promise to fill in some details. Let me know if you want a working example for the docs."}}