emojionearea icon indicating copy to clipboard operation
emojionearea copied to clipboard

Emojionearea won't get load if the input field is in *ngIf condition div in Angular.

Open Arjun-Shinojiya opened this issue 5 years ago • 2 comments

I am currently trying to use emojionearea library. The library works fine with input which comes on pages init. In that jquery gets loaded and I can select emoji in such input field but I have some input which shows only after a particular button click. In such inputs, the library won't able to get loaded. Maybe this is issue with jquery or NgIf condition. Please let me know if any solution is available for it. I also tried to initiate emojionearea in ngViewAfterViewChecked() but still its not working.

 ngAfterViewChecked() {
    $("#emojioneArea").emojioneArea({
      pickerPosition: "bottom"
    });
  }

Arjun-Shinojiya avatar Dec 11 '19 06:12 Arjun-Shinojiya

Use angular [hidden]= instead of NgIf.

See: https://stackoverflow.com/a/35578093/5297218

sebsobseb avatar Dec 13 '19 22:12 sebsobseb

You can create a directive that will works great... I'm developed this directive:

app.directive('emojiArea', ['sessionService',function(s){
  return {
    restrict: 'A',
    require: 'ngModel',
    link: function(scope,element,attr){
      var l = JSON.parse(s.get('lang'));
      angular.element(element).emojioneArea({
        search: false,
        useInternalCDN: true,
        buttonTitle: l['generic']['emojiarea'],
        pickerPosition: "bottom",
        autocomplete: false
      });
    }
  }
}]);

And on my textarea i use:

<textarea emoji-area ng-model="obj.myText"></textarea>

guicuton avatar Apr 16 '20 19:04 guicuton