Getting Started!
To get started you can simply clone the cidaas-sdk-angular2 repository and install the dependencies.
Prerequisites
You need git to clone the cidaas-sdk-js repository. You can get git from here
We also use a number of Node.js tools to initialize and test cidaas-sdk. You must have Node.js and its package manager (npm) installed. You can get them from here
Clone cidaas-sdk
Clone the cidaas-sdk-js repository using it:
git clone https://github.com/Cidaas/cidaas-sdk-angular2.git
cd cidaas-sdk-angular2
Install Dependencies
npm install
Run the Application
We have preconfigured the project with a simple development web server. The simplest way to start this server is:
npm start
Now browse to the app at localhost:5000/index.html
Directory Layout:
Usage
import { Component, OnInit, NgZone } from '@angular/core';
declare var window: any;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
constructor(private zone: NgZone) {
}
public username: string = "";
public usernav: boolean;
public nav: boolean;
public self: any;
title = 'app';
ngOnInit() {
window.my = window.my || {};
window.my.namespace = window.my.namespace || {};
window.my.namespace.userinfocall = this.userinfocall.bind(this);
this.username = "";
this.usernav = false;
this.nav = true;
this.self = this;
}
Login() {
window.doLogin();
}
Register() {
window.doRegister();
}
LogOut() {
window.doLogout(null, function () {
location.href = window.location.origin;
});
}
userinfocall(userinfo) {
this.zone.run(() => {
this.usernav = true;
this.nav = false;
this.username = "Welcome " + userinfo.displayName
})
}
}
For get user details simply call the userinfocall() funtion inside the cidaas.userinfo_callback() script method
The userinfo function call look like this my.namespace.userinfocall(userinfo)
Events
The user trigger some events:
doLogin() - This method allows user login to your portal/domain.
doRegister() - This method allows user register to your portal/domain.
doLogout() - This method allows user logout from your protal/domain and the user session also closed from domain.
userinfocall(userinfo) - This method allows user get them information with this information they can display their details how they want.
configuration
Configuare your project into cidaas, you want the cidaas script. Click here to know more about getting the script