Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

angularjs2 to post data to asp.net mvc controller

$
0
0

Hi,

I am trying to post data from angularjs2 to asp.net mvc controller.

The actual issue is that when I am trying with it then

See how am I trying ?

this is the typescript ---

  save(company: Company): Observable<boolean> {
        let headers = new Headers({ 'Content-Type': 'application/json' });
         this._http.post(this._postUrl, /*JSON.stringify(*/company/*)*/, { headers: headers })
            .subscribe(
             (data) => {
                console.log('Response');
                new Observable<true>()
            },
             (err) => { console.log(err); new Observable<false>(); },
            () => console.log('Complete')
            );

         return new Observable<false>();

          }

this is the call to this service function

 onSignUpClicked(message: string): void {
        this._service.save(this.company).subscribe(
           res => console.log(res),
            error => this.errorMessage = <any>error
        );

When I am debugging it (typescript) then it shows

  1. ConfirmPassword:"123"
  2. Name:"dfgfgf"
  3. Password:"123"
  4. UserName:"rer@fgfg.com"

Now see when it takes the control in the server side (MVC controller action) then it doesn't fill that data in the c# class.

see the snip below

https://1drv.ms/i/s!AitLVJhHEke3gewZXrXatheLUUytcw

Kindly guide me.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>