-
Notifications
You must be signed in to change notification settings - Fork 541
ng-change directive not working with tags-input #197
Comments
the reason your callback method isn't working is because you put the ng-change directive on the tags-input directive as a whole while i assume you want to target the tag collection or the underlying input field. the template of the tags-input looks something like this (it's not 100% accurate but you'll get the idea) <div>
<div id="tag collection">
<ul>
<li id="tag1">
<li id="tag2">
</ul>
</div>
<input id="inputField" />
</div> so basicly you add a In case you want to have a callback whenever a new tag is added you should use the <tags-input on-tag-added="onChange()"></tags-input> you can find more information about this in the documentation: |
Thanks for the response, I can go with the It is probably rather an feature than a bug. I think it would be possible to accomplish this through manual |
a solution you could use in the meantime is adding a <tags-input ng-model="tags"></tags-input> angular.module('app_module')
.controller('appCtrl', ['$scope',
function ($scope) {
$scope.tags = [];
$scope.$watchCollection('tags', function () {
// tag collection changed, do stuff here
});
}
]); |
Another solution would be to use both <tags-input ng-model="tags"
on-tag-added="tagChanged()"
on-tag-removed="tagChanged()">
</tags-input> |
@mbenford @alexanderjeurissen thank you guys, I have solved my issue for now. However, it would be great to add support for |
Closing due to inactivity. |
I have a use case where I want to see what the current value of the input text is so I can provide specific validation errors to the user ("The @ character isn't allowed", "That tag already exists", etc). There might be better ways to go about this than an on-input-changed event, but it seems like this satisfies my use-case and potentially others as well. I'll have a PR momentarily. Thanks for the awesome directive! |
Add an option for determining when the underlying input changes. This feature is important because it allows developers to know when the input has changed as well the state of the input at the time of the change. Closes mbenford#197.
Add an option for binding to the text in the input element. This feature is important because it allows developers to know when the input has changed as well the state of the input at the time of the change. An example use case is doing custom validations that regular expressions couldn't satisfy. Closes mbenford#197.
Add an option for binding to the text in the input element. This feature is important because it allows developers to know when the input has changed as well the state of the input at the time of the change. An example use case is doing custom validations that regular expressions couldn't satisfy. Closes mbenford#197.
Add an option for binding to the text in the input element. This feature is important because it allows developers to know when the input has changed as well the state of the input at the time of the change. An example use case is doing custom validations that regular expressions couldn't satisfy. Closes mbenford#197.
For whatever reason, the on-tag-added and on-tag-removed is not working. Here is my html:
what am I doing wrong? |
@robtcallahan do you have a plunkr demonstrating this? At a glance this looks ok. |
Add an option for binding to the text of the inner input element. This feature is important because it allows developers to know when the input has changed as well the state of the input at the time of the change. An example use case is doing custom validations that regular expressions couldn't satisfy. Closes #197
how a can watch current printing tag? |
i have faced same issue so you can use ngKeyup instead of ngChange .it will work fine |
I tried making a simple example based on this comment I'm having issues with these as well, they always seem to lag behind, I am always getting the ngModel how it was before the latest event, it looks like this event happens before the ngModel is updated. Here's how my code looks like <tags-input ng-model="firstCtrl.tags"
on-tag-added="otherCtrl.tagChanged(tags)"
on-tag-removed="otherCtrl.tagChanged(tags)">
</tags-input> I'm trying to get the list of tags to stay updated on another controller. |
@obahareth I was able to solve this by removing |
The onChange() method is not called when the "tags" model changes.
The text was updated successfully, but these errors were encountered: