In Angular2 I have a very simple form:
Form.ts
import {Component, Input} from 'angular2/core'
@Component({
selector: 'my-form',
providers: [],
template: `
<form>
{{ details }}
<input type="text" placeholder="name" />
<input *ngIf="details" type="text" placeholder="details" />
</form>
`,
directives: []
})
export class MyForm {
@Input() details: bool;
constructor() {
}
}
As shown in this Plunkr, when I toggle the details @input via the button, the text changes between true and false.
However the *ngIf isn't toggling the textfield at all.
Any thoughts on what I miss here?
App.ts
import {Component} from 'angular2/core'
import {MyForm} from './form'
@Component({
selector: 'my-app',
providers: [],
template: `
<div>
<button (click)="toggle()">toggle details</button>
<my-form details="{{visible}}"></my-form>
</div>
`,
directives: [MyForm]
})
export class App {
visible: boolean = false;
constructor() {
this.name = 'Angular2'
}
toggle() {
this.visible = !this.visible;
}
}