From 4a0651f425e06abcefa04c1a93135932fe4eebac Mon Sep 17 00:00:00 2001 From: mauriziovitale84 Date: Tue, 19 Apr 2016 14:06:53 +0100 Subject: [PATCH] Using let instead of var and relative template path ref #17 --- .../app/{style => components}/login.component.css | 0 .../app/{template => components}/login.component.html | 0 demo-shell-ng2/app/components/login.ts | 9 ++++++--- demo-shell-ng2/app/services/authentication.ts | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) rename demo-shell-ng2/app/{style => components}/login.component.css (100%) rename demo-shell-ng2/app/{template => components}/login.component.html (100%) diff --git a/demo-shell-ng2/app/style/login.component.css b/demo-shell-ng2/app/components/login.component.css similarity index 100% rename from demo-shell-ng2/app/style/login.component.css rename to demo-shell-ng2/app/components/login.component.css diff --git a/demo-shell-ng2/app/template/login.component.html b/demo-shell-ng2/app/components/login.component.html similarity index 100% rename from demo-shell-ng2/app/template/login.component.html rename to demo-shell-ng2/app/components/login.component.html diff --git a/demo-shell-ng2/app/components/login.ts b/demo-shell-ng2/app/components/login.ts index 8317f94fb8..efbadb7808 100644 --- a/demo-shell-ng2/app/components/login.ts +++ b/demo-shell-ng2/app/components/login.ts @@ -5,9 +5,10 @@ import {Authentication} from '../services/authentication'; @Component({ selector: 'login', + moduleId: 'app/components/login', directives: [ROUTER_DIRECTIVES, FORM_DIRECTIVES], - templateUrl: 'app/template/login.component.html', - styleUrls: ['app/style/login.component.css'], + templateUrl: 'login.component.html', + styleUrls: ['login.component.css'], }) export class Login { form:ControlGroup; @@ -29,7 +30,9 @@ export class Login { } onSubmit(value:any, event) { - event.preventDefault(); + if (event) { + event.preventDefault(); + } this.auth.login('POST', value.username, value.password) .subscribe( (token:any) => this.router.navigate(['Home']), diff --git a/demo-shell-ng2/app/services/authentication.ts b/demo-shell-ng2/app/services/authentication.ts index bda1ed9ca3..6fa8776a1f 100644 --- a/demo-shell-ng2/app/services/authentication.ts +++ b/demo-shell-ng2/app/services/authentication.ts @@ -2,7 +2,7 @@ import {Injectable} from 'angular2/core'; import {Observable} from 'rxjs/Rx'; import {Http, Headers, URLSearchParams, Response} from 'angular2/http'; -declare var xml2json:any; +declare let xml2json:any; @Injectable() export class Authentication {