import { Component } from '@angular/core';
import { NavController, ViewController } from 'ionic-angular';
import { HomeService } from './home.service';
export class User {
username: string;
password: string;
}
@Component({
selector: 'page-home',
templateUrl: 'home.html',
providers: [
HomeService
]
})
export class HomePage {
user: User = {
username: '',
password: ''
}
items:any;
constructor(public navCtrl: NavController, public service: HomeService) { }
login() {
this.service.getFunctions(this.user)
.subscribe(
datas => {
if(datas)
console.log(datas)
});
}
}
This is my home.ts it returns me in 2 ways:
If the login and password are correct it returns me:
Object {result: true, dados: object}
dados: Object
ID:"1"
LOGIN:"otacio"
NAME: “OTACIO”
If they are wrong, it returns me:
Object {result: false, msg: “INCORRECT USER”}
What I need:
When the result is true direct to the page: menu
When the result is false display invalid user message or password.
I know the question may be simple, but it is that I am starting in ionic and angular now.
General information:
Ionic Version: 2.2.1
Node Version:v7.5.0