I used electron-forge to create a new electron project that uses angular 2
npm install -g electron-forge
electron-forge init -t angular2
Then I added @angular/forms
yarn add @angular/forms
Then I edited the app.components.ts file to look like this
import { NgModule } from '@angular/core';
import {FormsModule} from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'App',
template:
`<div>
<h2>Welcome to {{name}} Angular2!</h2>
{{name}}
<input [(ngModel)] = "name">
</div>`
})
export class AppComponent implements OnInit {
public name = 'electron-forge';
ngOnInit(): void {
console.log('component initialized');
}
}
@NgModule({
imports: [BrowserModule, FormsModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
Two way binding is not working...when I change the text in my input control, the name filed is not changing
What am I missing?
I figured out the problem.
I had to load zone.js and reflect-metadata in index.html instead of bootstrap.ts. So when I did this
This worked. I had to remove this
From bootstrap.ts
Since it might be because you forgot to add FormsModule in the module.ts file.Check your app.module.ts
Related question