Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new MyClass(someArg);
- import {Component, OnInit} from 'angular2/core';
- export class App implements OnInit{
- constructor(){
- //called first time before the ngOnInit()
- }
- ngOnInit(){
- //called after the constructor and called after the first ngOnChanges()
- }
- }
- export class Users implements OnInit{
- user_list: Array<any>;
- constructor(private _userService: UserService){
- };
- ngOnInit(){
- this.getUsers();
- };
- getUsers(){
- this._userService.getUsersFromService().subscribe(users => this.user_list = users);
- };
- }
- export class Users implements OnInit{
- user_list: Array<any>;
- constructor(private _userService: UserService){
- };
- ngOnInit(){
- this.getUsers();
- };
- getUsers(){
- this._userService.getUsersFromService().subscribe(users => this.user_list = users);
- this.user_list.toUpperCase();
- };
- }
- import {Cmomponent, OnInit} from 'angular2/core';
- import {ExternalService} from '../externalService';
- export class app implements OnInit{
- constructor(myService:ExternalService)
- {
- this.myService=myService;
- }
- ngOnInit(){
- // this.myService.someMethod()
- }
- }
- export class User {
- email: string;
- password: string;
- lastLogin: Date;
- constructor(msg:string) {
- this.email = "";
- this.password = "";
- this.lastLogin = new Date();
- console.log("*** User class constructor " + msg + " ***");
- }
- Login() {
- }
- }
- import {Component} from "@angular/core";
- import {User} from "./../../shared/user/user"
- @Component({
- selector: "login-component",
- templateUrl: "pages/login/login.html",
- styleUrls: ["pages/login/login-common.css", "pages/login/login.css"]
- })
- export class LoginComponent {
- user: User = new User("property"); // ONE
- isLoggingIn:boolean;
- constructor() {
- this.user = new User("constructor"); // TWO
- console.log("*** Login Component Constructor ***");
- }
- ngOnInit() {
- this.user = new User("ngOnInit"); // THREE
- this.user.Login();
- this.isLoggingIn = true;
- console.log("*** Login Component ngOnInit ***");
- }
- submit() {
- alert("You’re using: " + this.user.email + " " + this.user.lastLogin);
- }
- toggleDisplay() {
- this.isLoggingIn = !this.isLoggingIn;
- }
- }
- JS: *** User class constructor property ***
- JS: *** User class constructor constructor ***
- JS: *** Login Component Constructor ***
- JS: *** User class constructor ngOnInit ***
- JS: *** Login Component ngOnInit ***
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement