How to call Restful API in AngularJS 2.0 using JavaScript

I have sample code for the form, and now I want to publish this data to the Restful API. I checked the lot, but basically found TypeScript based results. I want to do this using only JavaScript. Is there a way to do this using JavaScript?

I want to call the Post API on the onSubmit event. Check out the sample code.

(function(app) {
  app.FormComponent = ng.core
    .Component({
      selector: 'form',
      templateUrl: 'app/form.component.html'
    })
    .Class({
      constructor: function() {      
      },
      onSubmit: function() {
        console.log(this.model);
        this.submitted = true;
      },
    });
})(window.app || (window.app = {}));
+4
source share

Source: https://habr.com/ru/post/1620755/


All Articles