<!-- one-way binding, as AngularJS --> {{ propertyFromClass }}
<!-- listening to DOM event $event is optional here --> <button (click)="methodFromClass($event)">
<!-- DOM property binding --> <a [href]="anotherProperty">{{ yetAnother }}</a>
<!-- the only two-way binding both ngModel property and ngModelChange event added --> <input [(ngModel)]="andAnother" />
@angular/cli
npm i -g @angular/cli
ng new PROJECT_NAME
import { BrowserModule } from '@angular/platform-browser';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { NgModule, Component, Input } from '@angular/core';
@Component({
selector: 'angular-counter',
template: `
<div class="centered">
<button (click)="setCount(count - 1)">
-
</button>
<span>{{count}}</span>
<button (click)="setCount(count + 1)">
+
</button>
</div>
`
})
class Counter {
@Input() count: number;
setCount(count: number) {
this.count = count;
}
}
@Component({ selector: 'angular-app', template: '<angular-counter [count]="10">' }) class App { }
@NgModule({
imports: [ BrowserModule ],
declarations: [ App, Counter ],
bootstrap: [ App ]
})
class AppModule { }
platformBrowserDynamic().bootstrapModule(AppModule);
package io.github.mat3e.demo
import io.reactivex.Observable
import org.springframework.stereotype.Component
import org.springframework.stereotype.Service
@Service
class DemoService {
fun getData(): Observable<String> {
return Observable.just(
"First",
"Second"
)
}
}
@Component
class DemoComponent(val service: DemoService) {
fun render() {
this.service.getData().subscribe { next -> println(next) }
}
}