0

I've this block in my html inside a modal called "MyModal"

<pre style="color: red;" class="help-text text-center" ng-if="!flag">{{ message }}</pre>

And this code in my component inside oninit and triggers when MyModal get closed

$('#MyModal').on('hidden.bs.modal', function (e) {
      this.message ="\n";
      this.flag = true;
      console.log('this.flag',this.flag);
    })

But after this the message is not getting hidden, can someone clarify please, thanks in advance

Jacopo Sciampi
  • 2,990
  • 1
  • 20
  • 44
  • Does this answer your question? [How to access the correct \`this\` inside a callback?](https://stackoverflow.com/questions/20279484/how-to-access-the-correct-this-inside-a-callback) – ruth Feb 26 '21 at 08:25
  • **1.** Try not to mix Angular and JQuery. They have the tendency to quickly get of control. **2.** Use arrow function: `on('hidden.bs.modal', (e) => { ... });` **3.** Are you using Angular or AngularJS? They are different. If you're using Angular, the directive is called `*ngIf` and not `ng-if`. It should be `*ngIf="!flag"`. – ruth Feb 26 '21 at 08:26

0 Answers0