Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###############################################
- no main.ts
- ###############################################
- import { NgModule } from '@angular/core';
- import { BrowserModule } from '@angular/platform-browser';
- import {
- FormsModule,
- ReactiveFormsModule
- } from '@angular/forms';
- import { AppComponent } from './app.component';
- @NgModule({
- declarations: [
- AppComponent
- // ... our declarations here
- ],
- imports: [
- BrowserModule,
- FormsModule, // <-- add this
- ReactiveFormsModule // <-- and this
- ],
- bootstrap: [ AppComponent ]
- })
- class FormsDemoAppModule {}
- ###############################################
- no app.component.ts
- ###############################################
- import { Component } from '@angular/core';
- @Component({
- selector: 'my-app',
- template: `
- <div class="ui raised segment">
- <h2 class="ui header">Demo Form: Sku</h2>
- <form #f="ngForm"
- (ngSubmit)="onSubmit(f.value)"
- class="ui form">
- <div class="field">
- <label for="skuInput">SKU</label>
- <input type="text"
- id="skuInput"
- placeholder="SKU"
- name="sku" ngModel>
- </div>
- <button type="submit" class="ui button">Submit</button>
- </form>
- </div>
- `
- })
- export class AppComponent {
- onSubmit(form: any): void {
- console.log('you submitted value:', form);
- }
- }
- ###############################################
- no index.html
- ###############################################
- <!DOCTYPE html>
- <html>
- <head>
- <script src="node_modules/core-js/client/shim.min.js"></script>
- <script src="node_modules/zone.js/dist/zone.js"></script>
- <script src="node_modules/reflect-metadata/Reflect.js"></script>
- <script src="node_modules/systemjs/dist/system.src.js"></script>
- <script src="systemjs.config.js"></script>
- <script type="text/javascript">
- System.import('app').catch(console.log.bind(console));
- </script>
- </head>
- <body>
- <my-app></my-app>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement