I make a custom directive. Now I pass string data from the chips-break attribute and convert it to an array from the link method. It works, but when I get the array length inside the ng-keydown method, it is different.
HTML
<input-chips chips-break="32, 13, 188" style="width:80%"></input-chips>
JS
var app = angular.module("myApp", []);
app.directive("inputChips", inputChipsFun);
function inputChipsFun(){
return{
restrict : 'EA',
scope : {
chipsBreak : "@"
},
template: '<div class="chips"><div class="chips-item"></div><input type="text" ng-keydown="inputKeyDown($event, false)"/></div>',
link : function(scope, elem, attr){
scope.chipsBreak = scope.chipsBreak.split(",");
console.log("Length of Chips Break First Time = "+scope.chipsBreak.length);
scope.inputKeyDown = function($event, is_blur){
console.log("Length of Chips Break Key Press = " + scope.chipsBreak.length);
}
}
};
}
See this link: https://plnkr.co/edit/RpDwaqjS81DZlZFEzdj2?p=preview
Open inspect element console and type some things and see the difference.