Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Promise #1

Open
koeckc opened this issue Apr 30, 2016 · 2 comments
Open

Problem with Promise #1

koeckc opened this issue Apr 30, 2016 · 2 comments

Comments

@koeckc
Copy link

koeckc commented Apr 30, 2016

Hi,
I integrated your directive and i really like the style and the behaviour.
Everything works nice with local data.
The only problem that i have is that i cant get it to work with remote data.

I followed the instructions on using promises but it does not work ...
I try to use ng-change and a http get request to query the server.
Everytime when i assign the result to the defined promise everything duddenly stops working.. even ng change does not fire anymore.

Do you have a tip or an example how to use your module with remote date ?
thx in advance
constantin

@davidkonrad
Copy link
Owner

Hey @koeckc - can you provide a little example of what you are doing? I am aware that this "promise" thing not is very well written, it is a quick workaround and really needs both a makeover (perhaps real promises) and a working demo / example. I'll take a look at it now / this evening and will comment back.

@koeckc
Copy link
Author

koeckc commented Apr 30, 2016

Thx for the fast response .. maybe this snippets clarify what i want to do

//view code
<input autocomplete="off" bs3-typeahead bs3-source="states" class="form-control" type="text" ng-change="typeAhead()" ng-model="issue.room" name="room" <% unless @can_edit %> disabled="disabled"<% end %> id="room"> </input>

//on controller init
$scope.states = []

$http.get('/api/' + window.customerid + '/projects/' + window.projectid + '/issues' + '/auto_complete_room', {headers: {'Cache-Control': 'no-cache'}}).then(function (result) {
   $scope.states = result.data;
});

 $scope.typeAhead = function () {
   //this returns the promise
   $scope.states = $http.get('/api/' + window.customerid + '/projects/' + window.projectid + '/issues' + '/auto_complete_room',{ headers: { 'Cache-Control' : 'no-cache' } });
 }

 //i also tried with fetching the promise onSuccessCallback

After assigning to the the $scope.states variable nothing works anymore ... but the initial values from controller init work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants