You can initialize the booking.com booking form 1 time, but not again using ngOnInit

So, I am using angular materials with angular4, and I have posted the html for the booking.com form inside the MdDialogue component. I want this dialog to pop up with a form inside it when someone clicked a button. It works as expected 1 time after downloading the application, but not again. I would like it to work every time. There is no error message, so it’s not clear to me why this is happening. The logic inside booking () initializes the form.

The html form for booking.com is as follows.

<ins class="bookingaff" data-aid="1179852" data-target_aid="1179846" data-prod="nsb" data-width="100%" data-height="auto">
  <!-- Anything inside will go away once widget is loaded. -->
  <a href="//www.booking.com?aid=1179846">Booking.com</a>
</ins>

This is what booking.com component looks like ...

...
     openBookings(){
        let dialogRef = this.dialog.open(Booking_com);
        dialogRef.afterClosed().subscribe(result => {
        });
      }

      debug(data){
        console.log(data);
      }



    }

    @Component({
      selector: 'Booking_com',
      templateUrl: 'Booking_com.html',
      styleUrls: ['Booking_com.sass']
    })
    export class Booking_com implements AfterViewInit{


      ngAfterViewInit(): void {
        this.booking();
      }

      constructor(public dialogRef: MdDialogRef<Booking_com>) {}


      booking(){
        (function(d, sc, u) {
          var s:any =  d.createElement(sc);
          var p:any =  d.getElementsByTagName(sc)[0];
          s.type = 'text/javascript';
          s.async = true;
          s.src = u + '?v=' + (+new Date());
          p.parentNode.insertBefore(s,p);
        })(document, 'script', '//aff.bstatic.com/static/affiliate_base/js/flexiproduct.js');
      }
    }

The images show that it works for the first time, but not the second time .... Any idea of ​​why this is happening and how to solve this problem would be great.

This works for the first time when the pink button is pressed

This does not work a second time when you press the pink button

+6
1

script, , script BookingAff.run(), :

function u() {
  if (_i_("5fc:14"), u.already_ran) return _r_();
  u.already_ran = !0;

, already_ran . :

// reset already_ran flag
if (window.BookingAff && window.BookingAff.run.already_ran) {
  window.BookingAff.run.already_ran = false;
}

- .

, booking.com bstatic.com :

var r, i = new RegExp("(booking|bstatic).com$");
if (!e.origin.match(i)) return _r_();

BookingAff.run() .

- booking() (, already_ran).

plunker: https://plnkr.co/edit/IlAa7XJDjQIxd6IgKXIe?p=preview

JS,

ERROR: "dialog-overview-example-dialog"

Google https://material.angular.io/components/component/dialog plunker

+7

All Articles