title: Calling a function inside same class not working, typescript
body: <p>I am new to typescript and I am having a problem with calling a function inside the same class:
  I have a function like this:</p>
  
  <pre><code>createPost(url: String, data: any) {
      $.ajax({
        url: url + "/" + GLOBAL.REGISTER_URL,
        type: "POST",
        data: data.serialize(),
        success: function() {
          console.log("success");
        },
        error: function(request, status, error) {
          console.log(request.responseText);
          console.log(status);
          console.log(error);
        }
      });
    }
  </code></pre>
  
  <p>And I am trying to call it here:</p>
  
  <pre><code>.on('success.form.bv', function(e) {
          $('#success_message').slideDown("slow"); // Do something ...
          $('#contact_form').data('bootstrapValidator').resetForm();
  
          // Prevent form submission
          e.preventDefault();
  
          // Get the form instance
          var $form = $(e.target);
  
          // Get the BootstrapValidator instance
          var bv = $form.data('bootstrapValidator');
  
          // XXX reassigning port for testing purposes only
          var result = "https://" + window.location.hostname + ":" + GLOBAL.PORT + "/" + GLOBAL.VERSION + "/rest" + GLOBAL.REGISTER_URL;
  
          this.createPost(result, $form);
        });
  </code></pre>
  
  <p>But this is not working, every time when I click the button, I got a error in the browser:</p>
  
  <blockquote>
    <p>ERROR TypeError: this.createPost is not a function Stack trace:
    ../../../../../src/app/register/register.component.ts/RegisterComponent.prototype.ngOnInit/&lt;@<a href="http://localhost:4200/main.bundle.js:839:13" rel="nofollow noreferrer">http://localhost:4200/main.bundle.js:839:13</a>
    dispatch@<a href="http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:3:10263" rel="nofollow noreferrer">http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:3:10263</a>
    add/q.handle@<a href="http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:3:8325" rel="nofollow noreferrer">http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:3:8325</a>
    trigger@<a href="http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:4:5806" rel="nofollow noreferrer">http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:4:5806</a>
    trigger/&lt;@<a href="http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:4:6310" rel="nofollow noreferrer">http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:4:6310</a>
    each@<a href="http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:2:2813" rel="nofollow noreferrer">http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:2:2813</a>
    each@<a href="http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:2:1001" rel="nofollow noreferrer">http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:2:1001</a>
    trigger@<a href="http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:4:6289" rel="nofollow noreferrer">http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:4:6289</a>
    _submit@<a href="http://localhost:4200/assets/js-lib/bootstrapValidator.js:549:13" rel="nofollow noreferrer">http://localhost:4200/assets/js-lib/bootstrapValidator.js:549:13</a>
    validate@<a href="http://localhost:4200/assets/js-lib/bootstrapValidator.js:857:13" rel="nofollow noreferrer">http://localhost:4200/assets/js-lib/bootstrapValidator.js:857:13</a>
    _init/&lt;@<a href="http://localhost:4200/assets/js-lib/bootstrapValidator.js:109:21" rel="nofollow noreferrer">http://localhost:4200/assets/js-lib/bootstrapValidator.js:109:21</a>
    dispatch@<a href="http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:3:10263" rel="nofollow noreferrer">http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:3:10263</a>
    add/q.handle@<a href="http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:3:8325" rel="nofollow noreferrer">http://localhost:4200/assets/js-lib/jquery-3.1.1.min.js:3:8325</a>
    ../../../../zone.js/dist/zone.js/http://localhost:4200/polyfills.bundle.js:2839:17
    onInvokeTask@<a href="http://localhost:4200/vendor.bundle.js:49785:24" rel="nofollow noreferrer">http://localhost:4200/vendor.bundle.js:49785:24</a>
    ../../../../zone.js/dist/zone.js/http://localhost:4200/polyfills.bundle.js:2838:17
    ../../../../zone.js/dist/zone.js/http://localhost:4200/polyfills.bundle.js:2606:28
    ../../../../zone.js/dist/zone.js/http://localhost:4200/polyfills.bundle.js:2913:24
    invokeTask@<a href="http://localhost:4200/polyfills.bundle.js:3785:9" rel="nofollow noreferrer">http://localhost:4200/polyfills.bundle.js:3785:9</a>
    globalZoneAwareCallback@<a href="http://localhost:4200/polyfills.bundle.js:3803:17" rel="nofollow noreferrer">http://localhost:4200/polyfills.bundle.js:3803:17</a></p>
  </blockquote>
  
  <p>This should be a simple function call, and I don't know what is going on, can anyone help me with this problem?</p>