为什么这个组件在这个简单的插件中
@Component({
selector: 'my-app',
template: `<div>I'm {{message}} </div>`,
})
export class App {
message:string = 'loading :(';
ngAfterViewInit() {
this.updateMessage();
}
updateMessage(){
this.message = 'all done loading :)'
}
}
Run Code Online (Sandbox Code Playgroud)
投掷:
例外:App @ 0:5'中的表达式'我'{{message}}在检查后发生了变化.上一个值:'我正在加载:('.当前值:'我已经完成了加载:)'在[我是{{message}}在App @ 0:5中]
什么时候我正在做的是在我的视图启动时更新一个简单的绑定?
我有一个简单的表单,需要验证输入的开头和结尾是否不是空格.
在HTML5中,我将这样做:
<input type="text" pattern="^(?!\s|.*\s$).*$">
Run Code Online (Sandbox Code Playgroud)
新Angular 2 ngControl指令中验证模式的正确属性是什么?官方Beta API仍缺乏此问题的文档.
致力于angular2 beta Forms.经过大量的搜索后发现没什么用处.希望这里有人帮助我.
基本上我有点困惑如何以适当的方式使用angular2中的表单(即使用ngControl,ngFormControl等).我在这里创建了一个plnkr
这是我的.html代码: -
<form class="form-horizontal" id='myForm' role="form" [ngFormModel]="CreateGroup">
<div class="col-md-7">
Name: <input type="text" id="name" placeholder="Name" class="form-control" ngControl="name">
</div>
<div class="col-md-7">
Password: <input type="text" id="password" placeholder="password" class="form-control" ngControl="password">
</div>
<div class="col-md-7">
<input type="radio" name='type'>Btech
<input type="radio" name='type'>Mtech
</div>
<div class="col-md-7">
<input type="checkbox" >Math
<input type="checkbox">English
<input type="checkbox">Science
</div>
<br>
<div class="col-md-7">
<select #selectOption (change)='getValue(selectOption.value)' class='form-control'>
<option value='1'>One Value</option>
<option value='2'>two Value</option>
<option value='3'>Three Value</option>
</select>
</div>
</form>
<button type="button" (click)="addNewGroup(CreateGroup.value)" class="btn btn-primary btn-lg"> Create </button>
Run Code Online (Sandbox Code Playgroud)
和.ts代码在这里: …