-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Conversation
no test available
Hi @GuillaumeBiton,
|
Hi, I need some help unfortunately:
|
Hi @GuillaumeBiton. Great! We are getting there. EvalEval is indeed evil!! Instead in Angular we eval things against a scope Even better, we ought to watch this source expression for changes. On top of that I think we should not be tying ourselves to using the dataset. AngularJS will automatically match The easiest way of achieving this binding (i.e. watching and evaluating) is to add a property to the scope field on the directive definition object:
Angular will now keep the value of the expression in the source attribute in synch with the value of scope.source inside the directive. ControllerAt the moment it is no problem to have the controller declared inline inside the directive, but when you come to test, it can be easier to declare it separately, so that you can unit test the controller in isolation. FinallyCan you explain what this is for in the template?
|
@petebacondarwin, I don't know how to thank you. Thanks for the explanation on eval. It makes me understand lot of things that I have tried before with angular and directives. In template
this is a mistake. I forgot to delete these which was used in a first implementation attempt to bind the keyup events. |
thanks to @petebacondarwin advices
This is very nice. Good to merge but first one last thing. Can you move the array list in the demo into a controller in a separate file, demo.js? See the other modules for examples. |
@GuillaumeBiton This looks awesome, thnx so much for this pull request! At the moment I'm on something else but later today Peter or me will try to merge it into a separate branch and play with it. I will also try to stub some tests so you can extend them in a separate PR. There are other enhancements that can be added but this is a very good start! |
the maximum number of items display. Simply using the limitTo filter provides by AngularJS
One thing interesting with the typeahead jquery plugin of Bootstrap is that you can override some methods like matcher or sorter methods. It could be interesting to do the same with the angular version but I don't really know how to do it. |
@GuillaumeBiton All those things are possible and really easy - it is enough to specify an attribute that would accept an expression evaluating to a function. Then, we can get a hand of the actual function instance by invoking As soon as this is done we could use this function instance as a callback - basically invoking it any time we need to. I don't know if this explanation makes any sense but we will definitively have some iterations on this code. I would also like to add some unit tests before we add more features. With unit tests we can see how the directive behaves under different browsers. |
@petebacondarwin starting to look into this PR right now, please tell me if you were planning to do so as well so I can switch to something else. |
@GuillaumeBiton I think that I might have been a bit over-enthusiastic :-) This PR will require some more work. As I've said this is a good start but in reality it will have to be more complex that I've initially thought. The biggest problem, as for now, is that the implementation has an input buried in a template so I can't set any attributes on a input (for example - validation). This directive probably should be turned into an attribute one so I could use it on any existing input. The other problem - steaming from the first one - is that ng-model is bound to a transcluded scope so capturing model changes is not easy. On top of this the name of the ng-model is hard-coded to @GuillaumeBiton I know that the above might sound a bit cryptic so I will be toying with the code / ideas a bit and try to push into a separate branch in this repo. Feel free to ping me or @petebacondarwin if you need more info but for now it can't be merged as-is. |
@GuillaumeBiton I've hacked together an alternative approach where we can keep inputs (and |
@petebacondarwin, @pkozlowski-opensource, With your advices and the idea from pull request #57, I have modify the code. It's much simpler, allow to override some methods. So here in action : http://jsfiddle.net/guillaumebiton/sFNhJ/ Now I have to deal with these questions :
|
@GuillaumeBiton Just had a quick look. I will comment on some code fragments in the PR, but for me the main issue is that we don't have access to the input element as it is part of the template. This means that I can't:
I will let @petebacondarwin comment more but IMHO this directive should be an attribute on an input. As for yeoman - no, we are not using it at the moment, our build is based on Grunt.js + Testacular. BTW: Travis build is failing (lint issues). You should run |
@GuillaumeBiton I've just opened the issue #114 to discuss syntax of this directive. Your PR is a great inspiration but we need to discuss things a bit more before things get merged. Please join the discussion in #114! |
Update demo link in Readme
This is a typeahead directive purpose.
you can see it in action here :
http://jsfiddle.net/guillaumebiton/hNxF7/
Sorry but I need help for unit tests. never use. I am very interesting to learn how to set them.