Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event and property binding #1

Merged
merged 3 commits into from
Jul 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place your settings in this file to overwrite default and user settings.
{
}
34 changes: 0 additions & 34 deletions src/app/app.component.spec.ts

This file was deleted.

11 changes: 10 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,13 @@ import { Component } from '@angular/core';
})
export class AppComponent {
title = 'app works!';
}

toggle (){
//this.show = !this.show;
alert('sss');
}

}


}
2 changes: 1 addition & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';
import { innerComponent } from "./inner/inner.component";
import { innerComponent } from './inner/inner.component';

@NgModule({
declarations: [
Expand Down
21 changes: 21 additions & 0 deletions src/app/inner/inner.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
<p [title]="titleText">
{{title}}
</p>

<!-- <input type="text" (input)="clickMe($event)" /> -->
<hr/>
<h2>event binding and ngModel </h2>
<button [disabled]="!allowclick" (click)="onClicked()"> Click Me</button>
<input type="text" [(ngModel)]="EnteredData" placeholder="Typing..."/>
<p>{{ShowData}}</p>

<hr/>
<h2>NgStyle</h2>
<p [ngStyle]="{backgroundColor:getColor()}">The status is {{currentStatus}} -- {{getColor()}}</p>

<hr/>
<h2>*ngFor</h2>
<button (click)="addItems()"> Click Me</button>
<input type="text" [(ngModel)]="itemName" placeholder="Typing..."/>
<div *ngFor="let eachItem of repeatItems">
{{itemName}}
{{eachItem}}
{{title}}
</p>

Expand Down
41 changes: 35 additions & 6 deletions src/app/inner/inner.component.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

import { Component } from '@angular/core';
import {Component} from '@angular/core';

@Component({
selector: 'app-inner',
templateUrl: './inner.component.html',
styles: ['div, span{color:#666; font-size:14px;padding:5px 0}']
selector : 'app-inner',
templateUrl : './inner.component.html'
})

export class innerComponent {
export class innerComponent{
title = "innerComponent text";
titleText = "This is custom Text";


showFlag = 1;
view = "one"
colors = ['red', 'green', 'blue', 'pink', 'yellow'];
Expand All @@ -26,5 +26,34 @@ export class innerComponent {
name: 'Robbin', age: '32', gender: 'M'
}
]

allowclick = false;
currentStatus;

repeatItems = ['item 1','item2', 'item 3'];


constructor(){
setTimeout(() => {
this.allowclick = true;
},2000);

this.currentStatus = Math.random() > 0.5 ? 'Online' : 'Offline';

}

ShowData='';
EnteredData='';

}
onClicked (){
this.ShowData="'"+this.EnteredData + "' is textbox Data ";
}

getColor(){
return this.currentStatus ==='online' ? 'green' :'red';
}
eachItem = '';
addItems(){
this.repeatItems.push(this.eachItem);
}