Comments (13)
my way to solve ng-model binding:
add "searchStr: '=ngModel' in the directive's internal scope, like:
return {
restrict: 'EA',
require: '^?form',
scope: {
selectedObject: '=',
disableInput: '=',
......
inputName: '@',
searchStr: '=ngModel'
}
......
}
that can be use ng-Model as input element in form.
from angucomplete-alt.
What do you mean by predefining the selectedObject?
from angucomplete-alt.
For instance, when implementing CRUD functionality, updating a record in the form requires the model to be loaded and the fields populated with the current data. So essentially I have a field in my model that I've set to the selected-object but when its loaded the angucomplete field is blank.
// coming from sever
{ name: "Foo" }
// client side
....
selected-object="name"
....
I've already managed to find a workaround/alternative. I simply hide the field and show a label with the data if its defined then allow the user to click an "edit" link that will clear the data, hide the label and show the field.
from angucomplete-alt.
Would it be useful if we have direct two-way bind mode?
Currently there is an internal ng-model in the directive.
But if is just regular two-way bind model, this kind of behavior is easier.
from angucomplete-alt.
It might be useful. However, since it seems I'm the only one with this issue, I wonder if people are generally satisfied with the default behaviour. If it's not going to break the current API and it's easier to maintain then go for it! otherwise i'd wait for more people to request the feature/enhancement.
from angucomplete-alt.
+1
from angucomplete-alt.
Being able to set initial value for the internal model would help?
The usecase I'm thinking about is updating a model such as say user model that has
name: 'John'
age: 28
country: 'New Zealand'
With this user model, I might use angucomplete-alt for selecting country.
For creating, you can use the directive as it is.
But for updating, the form needs to start with initial value, 'New Zealand', then it should be able to update with new value.
So, I thought being able to set the initial value for internal model solve this usecase.
Please take a look at the latest commit in which I added initial-value feature. I also added one example for this. http://ghiden.github.io/angucomplete-alt/
from angucomplete-alt.
@ghiden yes your idea is exactly what's needed, but I have a little problem with it.... I'm loading the models from a backend, which is why it always results in a blank string at linking time, the initial-value
seems like it doesn't work, however I've tested it with an explicitly set string and tada it worked like magic, but in most cases a user doesn't have the string ready while the directive is still at linking phase, I've created a PR #26.
Thanks for keeping this handy module maintained and updated :)
from angucomplete-alt.
Yes, this is exactly what I'm looking for and I especially like the fact that you've added input-changed
as this was another thing i had to (trivially) workaround. I haven't tested it myself as yet but the demo seems to have the right behavior. Thanks for all your hard work.
from angucomplete-alt.
I have used ng-init to populate the data for the selected-object instead of initial-value (initial-value seems to only fill the value for the textbox).
from angucomplete-alt.
this solved ng-model binding for me :
first add to the scope inside the return :
return {
restrict: 'EA',
require: '^?form',
scope: {
ngModel: '=',
}
second add to the link function :
scope.$watch('ngModel', function(value, old){
// console.log(value)
scope.searchStr = scope.ngModel;
});
i know it is bad messing with the core but it was necessary for my project.
Thanks for this good plugin
from angucomplete-alt.
👍
from angucomplete-alt.
Use initial-value with object.
from angucomplete-alt.
Related Issues (20)
- Autocomplete-alt
- Console error message
- Angucomplete-alt
- Filtered result disappearing In IE if the data is large
- Tap on Autocomplete-alt dropdown causes updating results on android HOT 6
- Angucomplete-alt : one error results from the $injector being unable to resolve a required dependency after adding the angucomplete-alt module to my Angular App file, e.g.
- After adding the angucomplete-alt module to my Angular App file, I got an error 'being unable to resolve a required dependency' on console. What's wrong?
- Duplicate ng-focus on input
- .title not working when selected-object is a function
- How to pass index into selected-object HOT 1
- If data comes in binary format in name filed then it is going to be ng-invalid.
- Error: [$injector:modulerr]
- Unable to get the data with proper format in HTML in angular js
- Using arrow down starts from the second item HOT 1
- Using arrows may leave inconsistent value in the input field HOT 1
- RemoteUrlErrorCallback is undefined
- Address Auto Complete not working on Mozilla Firefox but working on Chrome and IE
- Custom search doesn't trigger function within controller HOT 1
- *.md
- angucomplete-alt select issue HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angucomplete-alt.