Post json data onclick button AngularAngular HTML bindingHow to detect a route change in Angular?Angular EXCEPTION: No provider for HttpAngular - Set headers for every requestAngular 2 data attributesWhat is the equivalent of ngShow and ngHide in Angular 2+?Angular/RxJs When should I unsubscribe from `Subscription`Huge number of files generated for every Angular projectCould not find module “@angular-devkit/build-angular”Post data to API with or without subscribe

Why is there a need to prevent a racist, sexist, or otherwise bigoted vendor from discriminating who they sell to?

Dereferencing a pointer in a 'for' loop initializer creates a segmentation fault

Was the 2019 Lion King film made through motion capture?

Can I call myself an assistant professor without a PhD?

Why did Gandalf use a sword against the Balrog?

A stranger from Norway wants to have money delivered to me

Infeasibility in mathematical optimization models

Visa National - No Exit Stamp From France on Return to the UK

Why does Intel's Haswell chip allow FP multiplication to be twice as fast as addition?

Generator for parity?

How should an administrative assistant reply to student addressing them as "Professor" or "Doctor"?

How quickly could a country build a tall concrete wall around a city?

In reversi, can you overwrite two chips in one move?

How do I explain to a team that the project they will work on for six months will certainly be cancelled?

Author changing name

Look mom! I made my own (Base 10) numeral system!

Drawing complex inscribed and circumscribed polygons in TikZ

What does "sardine box" mean?

As a 16 year old, how can I keep my money safe from my mother?

Why are Gatwick's runways too close together?

Why couldn't soldiers sight their own weapons without officers' orders?

Are any jet engines used in combat aircraft water cooled?

How can a surrogate pass on genes to a fertilized embryo?

What's this thing in a peltier cooler?



Post json data onclick button Angular


Angular HTML bindingHow to detect a route change in Angular?Angular EXCEPTION: No provider for HttpAngular - Set headers for every requestAngular 2 data attributesWhat is the equivalent of ngShow and ngHide in Angular 2+?Angular/RxJs When should I unsubscribe from `Subscription`Huge number of files generated for every Angular projectCould not find module “@angular-devkit/build-angular”Post data to API with or without subscribe






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I want to post json data when button click from typescript file



This is typescript file




type: 'button',
id: 'save',
className: 'btn btn-primary save-template',
events:
click: evt =>
_this.save();
(<any>config).opts.onSave(evt, _this.data.formData);

this.formData = new FormData();
this.formData.append("Form", JSON.stringify(_this.data.formData));
this.dataService.addItem(this.formData).subscribe(
data =>

);


].concat(options.actionButtons);


Here is my service



 addItem(data: FormData) 
const postForm = new HttpRequest('POST', `$this.API_URL/FormTemplates/PostFormTemplate`, data,
reportProgress: true
);
return this.httpClient.request(postForm);



Error i have face is cannot read property 'addItem' of undefined



Edit



save(stage = null) 
let _this = this;
let data = this.data;
if (!stage)
stage = this.d.stage;

let doSave =
xml: () => _this.xmlSave(stage),
json: () =>
(<any>window).JSON.stringify(_this.prepData(stage), null, 't')
;

// save action for current `dataType`
data.formData = doSave[(<any>config).opts.dataType](stage);

// trigger formSaved event
document.dispatchEvent(events.formSaved);
return data.formData;










share|improve this question





















  • 3





    I think in the context you're using the this keyword there's no dataService. Consider saving this before using it (e.g., const that = this;)

    – dcg
    Mar 27 at 7:45







  • 3





    Are you injecting dataService in your component. Please post a more complete code example

    – ashish.gd
    Mar 27 at 7:45











  • @ashish.gd Yes i have injected service to comonent

    – Ronak Dumaniya
    Mar 27 at 8:08











  • It would help if you can share a more complete code example.

    – ashish.gd
    Mar 27 at 8:14











  • @ashish.gd _this.data.formData here i got json form data but when it try to call service i got error which i have mention

    – Ronak Dumaniya
    Mar 27 at 8:19

















0















I want to post json data when button click from typescript file



This is typescript file




type: 'button',
id: 'save',
className: 'btn btn-primary save-template',
events:
click: evt =>
_this.save();
(<any>config).opts.onSave(evt, _this.data.formData);

this.formData = new FormData();
this.formData.append("Form", JSON.stringify(_this.data.formData));
this.dataService.addItem(this.formData).subscribe(
data =>

);


].concat(options.actionButtons);


Here is my service



 addItem(data: FormData) 
const postForm = new HttpRequest('POST', `$this.API_URL/FormTemplates/PostFormTemplate`, data,
reportProgress: true
);
return this.httpClient.request(postForm);



Error i have face is cannot read property 'addItem' of undefined



Edit



save(stage = null) 
let _this = this;
let data = this.data;
if (!stage)
stage = this.d.stage;

let doSave =
xml: () => _this.xmlSave(stage),
json: () =>
(<any>window).JSON.stringify(_this.prepData(stage), null, 't')
;

// save action for current `dataType`
data.formData = doSave[(<any>config).opts.dataType](stage);

// trigger formSaved event
document.dispatchEvent(events.formSaved);
return data.formData;










share|improve this question





















  • 3





    I think in the context you're using the this keyword there's no dataService. Consider saving this before using it (e.g., const that = this;)

    – dcg
    Mar 27 at 7:45







  • 3





    Are you injecting dataService in your component. Please post a more complete code example

    – ashish.gd
    Mar 27 at 7:45











  • @ashish.gd Yes i have injected service to comonent

    – Ronak Dumaniya
    Mar 27 at 8:08











  • It would help if you can share a more complete code example.

    – ashish.gd
    Mar 27 at 8:14











  • @ashish.gd _this.data.formData here i got json form data but when it try to call service i got error which i have mention

    – Ronak Dumaniya
    Mar 27 at 8:19













0












0








0








I want to post json data when button click from typescript file



This is typescript file




type: 'button',
id: 'save',
className: 'btn btn-primary save-template',
events:
click: evt =>
_this.save();
(<any>config).opts.onSave(evt, _this.data.formData);

this.formData = new FormData();
this.formData.append("Form", JSON.stringify(_this.data.formData));
this.dataService.addItem(this.formData).subscribe(
data =>

);


].concat(options.actionButtons);


Here is my service



 addItem(data: FormData) 
const postForm = new HttpRequest('POST', `$this.API_URL/FormTemplates/PostFormTemplate`, data,
reportProgress: true
);
return this.httpClient.request(postForm);



Error i have face is cannot read property 'addItem' of undefined



Edit



save(stage = null) 
let _this = this;
let data = this.data;
if (!stage)
stage = this.d.stage;

let doSave =
xml: () => _this.xmlSave(stage),
json: () =>
(<any>window).JSON.stringify(_this.prepData(stage), null, 't')
;

// save action for current `dataType`
data.formData = doSave[(<any>config).opts.dataType](stage);

// trigger formSaved event
document.dispatchEvent(events.formSaved);
return data.formData;










share|improve this question
















I want to post json data when button click from typescript file



This is typescript file




type: 'button',
id: 'save',
className: 'btn btn-primary save-template',
events:
click: evt =>
_this.save();
(<any>config).opts.onSave(evt, _this.data.formData);

this.formData = new FormData();
this.formData.append("Form", JSON.stringify(_this.data.formData));
this.dataService.addItem(this.formData).subscribe(
data =>

);


].concat(options.actionButtons);


Here is my service



 addItem(data: FormData) 
const postForm = new HttpRequest('POST', `$this.API_URL/FormTemplates/PostFormTemplate`, data,
reportProgress: true
);
return this.httpClient.request(postForm);



Error i have face is cannot read property 'addItem' of undefined



Edit



save(stage = null) 
let _this = this;
let data = this.data;
if (!stage)
stage = this.d.stage;

let doSave =
xml: () => _this.xmlSave(stage),
json: () =>
(<any>window).JSON.stringify(_this.prepData(stage), null, 't')
;

// save action for current `dataType`
data.formData = doSave[(<any>config).opts.dataType](stage);

// trigger formSaved event
document.dispatchEvent(events.formSaved);
return data.formData;







angular angular6 angular7






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 9:24







Ronak Dumaniya

















asked Mar 27 at 7:43









Ronak DumaniyaRonak Dumaniya

431 silver badge7 bronze badges




431 silver badge7 bronze badges










  • 3





    I think in the context you're using the this keyword there's no dataService. Consider saving this before using it (e.g., const that = this;)

    – dcg
    Mar 27 at 7:45







  • 3





    Are you injecting dataService in your component. Please post a more complete code example

    – ashish.gd
    Mar 27 at 7:45











  • @ashish.gd Yes i have injected service to comonent

    – Ronak Dumaniya
    Mar 27 at 8:08











  • It would help if you can share a more complete code example.

    – ashish.gd
    Mar 27 at 8:14











  • @ashish.gd _this.data.formData here i got json form data but when it try to call service i got error which i have mention

    – Ronak Dumaniya
    Mar 27 at 8:19












  • 3





    I think in the context you're using the this keyword there's no dataService. Consider saving this before using it (e.g., const that = this;)

    – dcg
    Mar 27 at 7:45







  • 3





    Are you injecting dataService in your component. Please post a more complete code example

    – ashish.gd
    Mar 27 at 7:45











  • @ashish.gd Yes i have injected service to comonent

    – Ronak Dumaniya
    Mar 27 at 8:08











  • It would help if you can share a more complete code example.

    – ashish.gd
    Mar 27 at 8:14











  • @ashish.gd _this.data.formData here i got json form data but when it try to call service i got error which i have mention

    – Ronak Dumaniya
    Mar 27 at 8:19







3




3





I think in the context you're using the this keyword there's no dataService. Consider saving this before using it (e.g., const that = this;)

– dcg
Mar 27 at 7:45






I think in the context you're using the this keyword there's no dataService. Consider saving this before using it (e.g., const that = this;)

– dcg
Mar 27 at 7:45





3




3





Are you injecting dataService in your component. Please post a more complete code example

– ashish.gd
Mar 27 at 7:45





Are you injecting dataService in your component. Please post a more complete code example

– ashish.gd
Mar 27 at 7:45













@ashish.gd Yes i have injected service to comonent

– Ronak Dumaniya
Mar 27 at 8:08





@ashish.gd Yes i have injected service to comonent

– Ronak Dumaniya
Mar 27 at 8:08













It would help if you can share a more complete code example.

– ashish.gd
Mar 27 at 8:14





It would help if you can share a more complete code example.

– ashish.gd
Mar 27 at 8:14













@ashish.gd _this.data.formData here i got json form data but when it try to call service i got error which i have mention

– Ronak Dumaniya
Mar 27 at 8:19





@ashish.gd _this.data.formData here i got json form data but when it try to call service i got error which i have mention

– Ronak Dumaniya
Mar 27 at 8:19












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372064%2fpost-json-data-onclick-button-angular%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372064%2fpost-json-data-onclick-button-angular%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현