Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度2将形式赋值给不起作用的变量“f=”;表格「;(提交)=;onSubmit(f.value)“;_Angular_Meteor_Angular2 Forms_Angular2 Directives - Fatal编程技术网

Angular 角度2将形式赋值给不起作用的变量“f=”;表格「;(提交)=;onSubmit(f.value)“;

Angular 角度2将形式赋值给不起作用的变量“f=”;表格「;(提交)=;onSubmit(f.value)“;,angular,meteor,angular2-forms,angular2-directives,Angular,Meteor,Angular2 Forms,Angular2 Directives,我正在学习流星角2教程。在angular 2 form中,使用hash f equals form绑定表单到变量f,然后绑定onSubmit函数。两个都不适合我。Angular 2 API是否已更改 无法使用HTML: <form #f="form" (submit)="addParty(f.value)"> <div>{{f.value}}</div> </form> 问题是缓存问题。通过本教程,第一个版本是缓存。不确定,但我认为meteo

我正在学习流星角2教程。在angular 2 form中,使用hash f equals form绑定表单到变量f,然后绑定onSubmit函数。两个都不适合我。Angular 2 API是否已更改

无法使用HTML:

<form #f="form" (submit)="addParty(f.value)">
  <div>{{f.value}}</div>
</form>

问题是缓存问题。通过本教程,第一个版本是缓存。不确定,但我认为meteor应该自动进行缓存破坏,但我需要手动删除缓存以使其正常工作。

问题在于缓存问题。通过本教程,第一个版本是缓存。不确定,但我认为meteor应该自动进行缓存破坏,但我需要手动删除缓存以使其正常工作。你可以回答自己的问题并接受它(在冷却一段时间后),然后它就不会因为没有回答而保持打开状态。
<form [ng-form-model]="partiesForm" #f="form" (submit)="addParty(f.value)">
  <label>Name</label>
  <input type="text" ng-control="name">
  <label>Description</label>
  <input type="text" ng-control="description">
  <label>Location</label>
  <input type="text" ng-control="location">
  <button>Add</button>
  <div>{{f}}</div>
  <div>{{f.value}}</div>
</form>
/// <reference path="../../typings/angular2-meteor.d.ts" />

import {Component, View} from 'angular2/angular2';

import {FORM_DIRECTIVES, FormBuilder, Control, ControlGroup, Validators} from 'angular2/angular2';

import {Parties} from 'collections/parties';

@Component({
    selector: 'parties-form'
})
@View({
    templateUrl: 'client/parties-form/parties-form.html',
    directives: [FORM_DIRECTIVES]
})
export class PartiesForm {
    partiesForm: ControlGroup;

    constructor() {
        var fb = new FormBuilder();
        this.partiesForm = fb.group({
            name: ['', Validators.required],
            description: [''],
            location: ['', Validators.required]
        });
        // Test
        console.log(this.partiesForm.value);
    }

    addParty(party) {
        console.log("assParty", party);
        return true;
        if (this.partiesForm.valid) {
            Parties.insert({
                name: party.name,
                description: party.description,
                location: party.location
            });

            (<Control>this.partiesForm.controls['name']).updateValue('');
            (<Control>this.partiesForm.controls['description']).updateValue('');
            (<Control>this.partiesForm.controls['location']).updateValue('');
        }
    }

}
console.log("PartiesForm loaded");
#f="form" (submit)="onSubmit(f.value)"