Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70765

Create a post method inside a class with empty constructor

$
0
0

@thilinanara wrote:

this is my class
.
export class publicip {
publicip: string;
constructor(private http:Http) {
//this.navCtrl.push(MainPage);
}

public getip(){
let headers = new Headers({‘Content-Type’:‘application/x-www-form-urlencoded’,‘Accept’:‘application/json’});
let options = new RequestOptions({headers:headers});
let credentials = “username=”+’’+"&password="+’’;
// index.php/rest_api_mobile/index_post
this.http.post(‘http://localhost/mechmarcl_website/index.php/Admin/getpublicip’, credentials, options).
map(res => res.json()).subscribe(
data => {

          if(data['status']==true && data['data']['login']==true){
            
            //Store user Info
            this.publicip=data['data'];
            console.log("done");
            console.log(this.publicip);              
          }else{                              
         }
        },
        err => {
          console.log("ERROR!: ", err);
        }
  );

}
}

what should i pass as the parameter when i call to this getip method from outside.

this.public = new publicip(’-----).getip();

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70765

Trending Articles



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