Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49381

Problem with subjectID

$
0
0

@dipankar123 wrote:

hi, i am new in ionic 2
i have get subjectID from another page through navParams
but when i implemented it in afunction found error:
"Uncaught (in promise): TypeError: Cannot read property ‘SubjectID’ of undefined"
here is my code:
in provider:
subjectBasedAttnd( AuthToken: string, SubjectID: string) {
let headers = new Headers({
‘AuthToken’: AuthToken
});

let options = new RequestOptions({
  headers: headers
});
return new Promise(resolve => {
  this.http.get("http://122.160.53.175:83/smartrollcall/api/WebRequest/GetDateWiseAttendance?StartDate="+" "+"&EndDate="+" "+"&SubjectID="+SubjectID, options)
    .map(res => res.json())
    .subscribe(
    data => { resolve(data) },
    err => { console.log(err) }
    );
});

}

in page.ts:
subject: any;
attendenceList: any;
item: any

constructor(public navCtrl: NavController,
public navParams: NavParams,
public storage: Storage,
public userProvider: UserProvider, ) {
this.subject = navParams.get(‘item’); // getting value

//console.log('id: ' + this.subject.SubjectID);
this.subjectAttendence();

}

subjectAttentList(){
return this.attendenceList;
}

subjectAttendence() {
console.log(‘subject clicked’);
this.storage.get(‘token’).then((value) => {
console.log('subtoken: ’ + JSON.parse(value).AuthToken);
this.userProvider.subjectBasedAttnd(JSON.parse(value).AuthToken, this.subject.SubjectID).then(data => {
console.log('list: ’ + data)
this.attendenceList = data;
});
});
}

ionViewDidLoad() {

console.log('ionViewDidLoad SubjectDetailsPage');

}

}

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 49381

Trending Articles



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