Skip to content

Commit

Permalink
Merge pull request #1 from ambujkhanna/Event-and-property-Binding
Browse files Browse the repository at this point in the history
Event and property binding
  • Loading branch information
ambujkhanna committed Jul 24, 2017
2 parents 0b8ae29 + 0d5b782 commit e3bbb9d
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 42 deletions.
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);
}

0 comments on commit e3bbb9d

Please sign in to comment.